使用 BuildEngine 传递 MsBuild 命令行参数
我有以下代码可以从另一个 C# 应用程序构建项目:
var buildEngine = new Engine();
buildEngine.RegisterLogger(new ConsoleLogger());
var success = buildEngine.BuildProjectFile(pathToCsProjFile);
if(!success)
{
Log.LogIt("On Noes! We Broke!");
}
else
{
Log.LogIt("It Worked!!!!!!");
}
当前它构建默认配置(调试),但我希望它构建发布版本。如果我从命令行调用 MsBuild,我会执行以下操作:
C:\Windows\WinFX\v3.5>msbuild.exe *.proj /ToolsVersion:3.5 /p:Configuration=Release
如何将该配置开关传递给构建引擎?
I have the following code to build a project from another C# app:
var buildEngine = new Engine();
buildEngine.RegisterLogger(new ConsoleLogger());
var success = buildEngine.BuildProjectFile(pathToCsProjFile);
if(!success)
{
Log.LogIt("On Noes! We Broke!");
}
else
{
Log.LogIt("It Worked!!!!!!");
}
Currently it builds the default configuration (Debug) but I want it to build the release version. If I were invoking MsBuild from the command line I would do something like:
C:\Windows\WinFX\v3.5>msbuild.exe *.proj /ToolsVersion:3.5 /p:Configuration=Release
How do I pass that configuration switch to the build engine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置该属性,类似这样的操作应该可以解决问题:
You'll want to set the property, something like this should do the trick:
使用
BuildProjectFile
的其他重载实现之一。我相信这个一个。创建一个BuildPropertyGroup
并添加所需的属性。在本例中“配置”=“发布”Use one of the other overloaded implementations of
BuildProjectFile
. I believe this one. Create aBuildPropertyGroup
and add the properties you want. In this case 'Configuration' = 'Release'