Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2010 build error - imported project "project_path" was not found

Have been trying to build a solution which contains a number of projects and keep getting a recurring error.

I have managed to get the build to partially succeed but always get the error shown below:

C:\Builds\1\MBS.Payments.Forms.Mvc\MBS Payment Forms MVC\Sources\MBS.Payments.Forms.Mvc\MBS.Forms.Payments.Web\MBS.Forms.Payments.Web.csproj (979): 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 declaration is correct, and that the file exists on disk.

I have navigated to the file in which the error is being generated where this code is highlighted:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"  Condition="'$(VSToolsPath)' != ''" />

Currently I have both Visual Studio 2010 Premium and a evaluation version of Visual Studio 2012 Ultimate installed, I am currently working on this application in Visual Studio 2010.

below is the code block in which the erroneous code is found:

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

Please could anyone advise on why this error is being generated and how it could be resolved.

like image 202
CryoFusion87 Avatar asked Nov 20 '12 11:11

CryoFusion87


2 Answers

Check the two locations:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications and C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications

Do either of these have the .targets file present? Personally I find it in both, but I'm guessing you don't (at least according to the error it's not in the v11.0 folder).

Your condition checks for VisualStudioVersion and VSToolsPath properties to see if they are missing, then sets them. One or both of these must be set already or it would be pointing to the v10.0 folder.

According to http://blogs.msdn.com/b/webdev/archive/2012/08/22/visual-studio-project-compatability-and-visualstudioversion.aspx, this is probably caused by opening the project in VS2012.

To fix, I'd either get a v11 copy of the .targets (there are some changes between the two from what I can see, maybe it wasn't correctly installed when you did the setup?) or revert to using the v10 version.

like image 56
Daniel Morritt Avatar answered Oct 02 '22 19:10

Daniel Morritt


If using Visual Studio 2013 or newer and TFS 2010, you can edit your Build Definition to include a new MSBuild argument.

/p:VisualStudioVersion=10.0

enter image description here

like image 29
Moojjoo Avatar answered Oct 02 '22 17:10

Moojjoo