問題描述
以下代碼嘗試使用 BuildManager
以編程方式構建解決方案:
The following code tries to build a Solution programmatically, using BuildManager
:
當我運行這段代碼時,它不會構建任何東西.我可以看到除了 winmdexp.exe
的一個特定版本之外,還使用了以下編譯器 csc.exe
:
When I run this code, it doesn't build anything. I can see that the following compiler csc.exe
is being used, in addition to one particular version of winmdexp.exe
:
但是當我使用 VS IDE 成功構建解決方案時,出現以下信息:
But when I successfully build a solution using VS IDE, the following information comes up:
為什么在我的代碼中會發生這種情況?怎么改?
Why is this happening in my code & how can I change it?
推薦答案
截至 Visual Studio 2013,MSBuild 不再是 .NET Framework 組件.這意味著對打包和部署進行了一些重組.舊的 MSBuild 框架仍然存在于 .NET Framework 文件夾中.但是,當您安裝 Visual Studio 2013 時,Microsoft Build Tools 12.0 也會安裝到 C:Program Files (x86)MSBuild12.0.請注意,構建工具與 Visual Studio 分開提供此處.
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)MSBuild12.0. Note that the Build Tools are available separately from Visual Studio here.
當我第一次嘗試這個時,我也遇到了和你一樣的情況.問題是您可能已經引用了舊的4.0"MSBuild Framework 程序集.您需要引用位于 C:Program Files (x86)MSBuild12.0in 中的新 12.0 程序集(您必須在 VS 中瀏覽以添加引用).您可能需要 Microsoft.Build、M??icrosoft.Build.Engine 和 Microsoft.Build.Framework.更新這些參考資料后,我發現它在構建時使用了與 VS 2013 相同的工具.
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)MSBuild12.0in (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.
這篇關于強制 BuildManager 使用另一個版本的 MSBuild的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!