I really like the fact that MSBuild is installed with the .Net Framework so you do not have to install a separate build tool. Unfortunately, if you are developing Web Application projects (WAP), you may discover something is missing.
In my case, I am building a VS2008 project and the build server does not have Visual Studio installed. No problem, right? Wrong.
It turns out that when you install VS, it deploys some additional targets to the MSBuildExtensionsPath. Without these targets, when you run the build, you will see:
error MSB4019: The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
This is in direct reference to your WAP *.csproj file.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
If you search for MSB4019
, you will find a few different resolutions. Here are a couple.
- Add a condition to the <Import> element that basically verifies the target file exists. Because you are modifying your csproj file directly, VS may warn you about it. I am not a great fan of this approach, but it appears to work. I think perhaps the reason is because the import is only necessary when building the project from within VS.
- Deploy the target files to your build server. I copied the entire contents of <MSBuildExtensionsPath>/Microsoft/Visual Studio from my development box (which has VS2008 installed) to the build server.
The same issue arises with VS2005.
Anyway, I hope this clarifies the issue and helps someone.