0
votes

We have two build servers and a newly created project has decided that it only wants to build successfully on one of them. It gives this error on the build server on which it fails:

MyLovelyNewProject.csproj(380,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\MSBuild.exe.Config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.

Our DevOps guy investigated and determined that one server has the v15.0 build tools and one of them has the v15.9 build tools. The new project fails to build on the server that has the v15.9 build tools, since it's specifically looking for the v15.0 build tools.

All of our other projects build just fine on both build servers, but I wasn't able to find anything in their .sln or .csproj files that looked different from the new project. How can I retarget/reconfigure the new project so that it will build successfully regardless of which version of the build tools a given server has?

(If you want to suggest that DevOps synchronize the build servers to have the same version of the build tools, I agree! Alas, they're busy with a major server migration, and I would like the new project to not have a 50% chance of failing in CI while they're getting around to it.)

1
Perhaps the following post will help: stackoverflow.com/questions/44061932/…user9938
Hi Oblivious, any update about this issue?Mr Qian
@PerryQian-MSFT Hi Perry, I don’t manage the build server but I passed on you recommendation to DevOps and they thought it sounded good and will try it in the next couple days as time permits.Oblivious Sage
@ObliviousSage, well. Hope your any feedback:)Mr Qian
@ObliviousSage, any update about this issue?Mr Qian

1 Answers

2
votes

I think the issue is related to the Build Tool v15.9 rather than your projects. On that Server, you did not install the build workload for web projects on V15.9 Build Tool so that it cannot specify the web projects and lack the ability to build web projects. Or, the build tool is broken due to some reasons.

You could try the following steps:

1) try to open the vs_installer, click Modify

enter image description here

And select Web development build tools workload to install, also, if you have a asp net core web projects, do not forget to install .Net Core build tools workload.

enter image description here

enter image description here

To ensure this, I remove the web development build tools workload, and get the same issue for web project.

enter image description here

2) If it does not help, please click Repair for Build Tool V15.9 to repair it.

enter image description here