BuildManager to use another version of MSBuild

后端 未结 1 1224
别那么骄傲
别那么骄傲 2020-12-03 12:24

The following code tries to build a Solution programmatically, using BuildManager:

ProjectCollection pc = new ProjectCollection();
pc.DefaultToo         


        
相关标签:
1条回答
  • 2020-12-03 12:39

    As of Visual Studio 2013, MSBuild is no longer a .NET Framework component. This meant some restructuring of packaging and deployment. The old MSBuild framework still lives in the .NET Framework folders. However when you install Visual Studio 2013, the Microsoft Build Tools 12.0 are also installed to C:\Program Files (x86)\MSBuild\12.0. Note that the Build Tools are available separately from Visual Studio here.

    I encountered the same situation as you as well when I first tried this. The issue is that you probably have referenced the old "4.0" MSBuild Framework assemblies. You need to reference the new 12.0 assemblies located in C:\Program Files (x86)\MSBuild\12.0\bin (you'll have to browse there in VS to add the references). You probably need Microsoft.Build, Microsoft.Build.Engine, and Microsoft.Build.Framework. Once I updated those references I saw it was using the same tools as VS 2013 when building.

    0 讨论(0)
提交回复
热议问题