The imported project Microsoft.WebApplications.targets was not found

<!--<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />-->

Comment above line in .CSproj. Seems like bug with Microsoft which do not remove or comment while updating project from visual studio 2008 to 2010.


I saw the same error when setting up continuous integration with Jenkins. I was able to add a command-line argument to MSBUILD: /p:VisualStudioVersion=12.0 because I had Visual Studio 2012 installed on my build server.


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.

You need to either...

  1. Install Visual Studio on your build machine, or
  2. Manually copy the contents of the MSBuild\Visual Studio\v10.0\WebApplications folder to the same location on your build machine.