Wednesday, 17 March 2010

ERROR: The imported project *******\Microsoft.WebApplication.targets was not found


I recently attempted to compile a project using MSBuild on a build server, but I came across the following error from MSBuild...

 <project dir="" name="MSBuild">
    <error code="MSB4019" message="The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the &lt;Import> declaration is correct, and that the file exists on disk." dir="\\testserver\CCNETBUILD\sampleproject\WebApp" name="WebApp.csproj" pos="(354, 11)" />
  </project>



Targets files usually come packaged with Visual Studio, so its strange as to why the .NET Framework runtime doesn't contain these files. There is a dependency on the Visual Studio SDK that isn't necessary and should not be installed onto a build server (unless compiling non-Wix setup projects [vdproj] files).

Therefore, we need to apply a workaround... The error message displays the file path where the target files are expected. We simply need to copy these target files to this directory. I took my from my development box. The same applies for any other target files missing as the result of a failed build.

No comments: