Tuesday, 4 March 2014

The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found.

This is another “How I got burnt” today post, so sharing here just in case anyone else finds the same issue. So, I moved one of my team project from TFS 2012 to TFS 2013. After moving the solution, I noticed that one of my builds start producing the following error

The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.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 build compiles a solution containing an ASP.Net MVC project, which is where it was complaining about. The solution was already migrated to Visual Studio 2013, so why was it complaining about files for Visual Studio 2012 (v11.0) not being found. Looking closely, it transpired to me that it might be the 2012 Team build template and indeed it was. Although, we have migrated our project to TFS 2013, we were still using the TFS 2012 Build template. The solution was simple – simply passing on the Visual Studio version as an MSBuild argument (as shown below) in the build definition and walla it’s all resolved.

msbuild arguments

10 comments:

Steve Vermeulen said...

Thanks for the post - I had the same issue

Hamid said...

Cheers Steve,
Glad that you found the post useful

Wanderer said...

Took a while to finally find someone else with the same problem!
Thank you.

MEMark said...

Great post. Also see this answer:
http://stackoverflow.com/a/21143575/268091

Vishav Premlall said...

Hey, I'm having a similar problem. im trying to open a solution for an apache cordova app that i was busy writing. It fails to open and the solution doesn't load, ever since my pc crashed.

I have reinstalled all the necessary prequisites. I put in a lot of work into this project so could someone please help me?

Hamid said...

Hi Vishav,
Have you got the Cordova application template installed on your machine? If it's not loading up the solution, looks like you don't have it.

charbaugh said...

Yep, this worked for me

Craig S. said...

You just saved me quite a few hours of investigation. Thanks.

Craig S. said...

I would like to add, that I did not need to pass /p:VisualStudioVersion=12.0 as a build parameter. Instead, I simply updated the build definition's template and "translated" the settings from the v11 template to the v12 template.

Sean Ivins said...

Beautiful. Thank you for this.