Question

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.

Was it helpful?

Solution 4

the <PropertyGroup></PropertyGroup> tag gets added to the project file when you open it in Visual Studio 2012, I was able to open the project file in a text editor, remove the PropertyGroup and it built successfully

OTHER TIPS

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.

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

As CryoFusion87 pointed out, the solution that worked for me was to remove the whole <PropertyGroup></PropertyGroup> tag and its content.

This tag is added to support opening projects from VS 2010 and VS 2012. See more in here: http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx

I am now using VS 2013 and this is not needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top