MSBuildWorkspace.OpenSolutionAsync searches for targets in Visual Studio / v14.0

I have a VS 2013 console application that downloads any solution file (.sln) - compiles all projects in it using Roslyn and extracts information about using the API from the compilation model.

Now I am facing this unusual problem. When I run the application from Visual Studio 2013 (using Ctrl-F5 or F5), everything works fine. I can compile the material and extract all the information. However, when I open a command prompt (cmd) and try to run this console application, I get the following error:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project " C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Impor When I run 

Pay attention to v14.0 . Why is MSBuildWorkspace trying to find the v14.0 directory for the required destination files? Is this because I installed MSBuild for CTP and changed the default path when I ran the material from a simple command line?

- Edit-- Here is the import

 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> 

However, I doubt that this is due to the Import statement as such. If I run the .exe console application from the "Developer Command Prompt for Visual Studio 2013", everything works fine again.

+6
source share
2 answers

You can make your web application projects standalone and not require compiling Visual Studio 2015 by adding a NuGet link to MSBuild.Microsoft.VisualStudio.Web.targets .

+6
source

I had this problem on my build server. When I targeted /tv:14.0 (Tool Version 14.0, which is the Roslyn build engine)

I solved this by selecting C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio, then creating folders like v14.0 \ WebApplications

Then I logged on to my system using Microsoft.WebApplication.targets (because it was released by Visual Studio 2015) and copied this file to a new folder with the build servers.

+2
source

Source: https://habr.com/ru/post/979920/


All Articles