Saturday, January 21, 2012

Microsoft.WebApplication.targets not found

Working on a recent project I noticed this annoying issue when I tried to open a large solution in Visual Studio composed of many different projects. Two of the projects were not loaded in the solution because of this, reporting the following on the output window:

The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

The problem as you can see is that the extensions file "Microsoft.WebApplication.targets" was not found. I was using Visual Studio 2010, so the first hint is that the project was looking for the extension file in the Visual Studio 2008 folder (v9.0) instead of VS 2010 (v10.0).

The simple solution? just copy the "WebApplications" folder from v10.0 to v9.0. Close the solution and re-open it again and it should work fine.

If you don't have Visual Studio 2010 installed or you can't find the file, chances are that you are missing some web components from the installation that are required to build/deploy/publish web applications. Try to find the files on-line or better yet, install Visual Studio 2010 and copy the files to your v9.0 folder. If you actually have Visual Studio 2010, you should actually make those projects point to the VS2010 folder instead of the VS2008 one.

Now, one thing to notice is that you might be having this issue on a build server instead of your local machine. If the build server is trying to build web applications you will probably get this error since it is likely that you don't have Visual Studio installed there, and that should be the case. It is against best practices to have VS installed on your build server, it is a NO-NO!. If this is your case, just copy your local files to the server and make sure they are in the same location. Also you would probably want to make sure that .NET Framework 4.0 is installed in the server.

Now, what is the purpose of this file and why it is needed? It basically contains extension entries required by MSBuild for deployment tasks of web applications.

Hope it helps. Cheers!

No comments:

Post a Comment