BuildManager使用的MSBuild的另一个版本 [英] BuildManager to use another version of MSBuild

查看:312
本文介绍了BuildManager使用的MSBuild的另一个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码试图以编程方式构建一个解决方案,使用 BuildManager

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

ProjectCollection pc = new ProjectCollection();
pc.DefaultToolsVersion = "12.0";
pc.Loggers.Add(fileLogger);
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
BuildRequestData buildRequest = new BuildRequestData(solutionName, globalProperty, null, new[] { "Build" }, null);

BuildParameters buildParameters = new BuildParameters(pc)
{
    DefaultToolsVersion = "12.0",
    OnlyLogCriticalEvents = false,
    DetailedSummary = true,
    Loggers = new List<Microsoft.Build.Framework.ILogger> { fileLogger }.AsEnumerable()
};

var result = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);

当我运行此代码(它没有构建任何东西顺便说一句),我可以看到以下编译 CSC.EXE 正在使用中,除了 winmdexp.exe 的一个特定版本:

When I run this code (it doesn't build anything btw), I can see that the following compiler csc.exe is being used, in addition to one particular version of winmdexp.exe:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Csc.exe
ExportWindowsMDFile:
    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\winmdexp.exe 

但是,当我成功地建立使用VS IDE的解决方案,以下信息出现:

But when I successfully build a solution using VS IDE, the following information comes up:

C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe
ExportWindowsMDFile:
    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\winmdexp.exe

这究竟是为什么在我的代码和放大器;我能怎样改变

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构建工具12.0也安装在C:\Program文件(x86)\MSBuild\12.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)\MSBuild\12.0. Note that the Build Tools are available separately from Visual Studio here.

我遇到同样的情况,你也当我第一次尝试这样做。问题是,你可能已经引用旧的4.0的MSBuild框架集。您需要引用位于C新的12.0组件:\Program文件(x86)\MSBuild\12.0\bin(你必须在VS浏览那里添加引用)。你可能需要Microsoft.Build,Microsoft.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)\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.

这篇关于BuildManager使用的MSBuild的另一个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆