I experienced something similar.
I had written this in our Autobuild.targets file run as part of a build. It defines MSWebApplicationTargets:
<MSWebApplicationTargets>$(SolutionDirectory)\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3</MSWebApplicationTargets>
Then in a .csproj file that is part of the project and used in the build it had:
<Import
Project="$(MSWebApplicationTargets)/tools/VSToolsPath/WebApplications/Microsoft.WebApplication.targets" />
Now our problem was that when we opened the project in Visual Studio it said that c:/tools/VSToolsPath/WebApplications/Microsoft.WebApplication.targets doesn't exist (because VS considered MSWebApplicationTargets to be undefined and so seemed to default it to c:\). You don't provide enough information though perhaps that is what caused your problem also.
All I had to do to solve this was add a condition:
<Import
Project="$(MSWebApplicationTargets)/tools/VSToolsPath/WebApplications/Microsoft.WebApplication.targets"
Condition="'$(MSWebApplicationTargets)' != ''" />
Why do this with Microsoft.WebApplication.targets
As part of some futher discussion, I did this with Microsoft.WebApplication.targets so we didn't have to rely on Visual Studio being installed on the build servers. I added it as a dependency:
- In Visual Studio right-click on the project and go to
manage nuget packages. This created a packages.config file that listed MSBuild.Microsoft.VisualStudio.Web.targets as a dependency.
- I then added
nuget.exe restore to the start of the build script so that the dependencies are downloaded.