运行编程的MSBuild [英] running msbuild programmatically
问题描述
我想的MSBuild programically执行并不能执行以下命令:
I am trying to execute msbuild programically and cant execute the following command:
string command = string.Format(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ""{0}\{1}.csproj""", _args.ProjectPath, _args.ProjectName);
字符串被渲染为:
the string gets rendered as:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "C:\...\TestResults\Foo 2011-08-31 16_29_40\Out\Foo\solutionName\projectName\projectName.csproj"
然后我用新的ProcessStartInfo(命令)。这个问题似乎是Foo和2011年。我得到下面的输出之间的空间:
I then use new ProcessStartInfo(command). The problem seems to be the space between Foo and 2011. I get the following output:
MSBUILD : error MSB1008: Only one project can be specified.
Switch: 16_29_40\Out\Foo\solutionName\projectName\projectName.csproj
我如何通过在项目文件的MSBuild?
How do I pass in the project file to msbuild?
推荐答案
我会建议stronlgy进去的 Microsoft.Build
命名空间。微软使用这个所有的地方,所以这应该算的东西...
I would recommend stronlgy to go the official route via classes/interfaces in Microsoft.Build
namespace. Microsoft uses this all over the place, so this should count for something...
ESP。类<一个href=\"http://msdn.microsoft.com/en-us/library/microsoft.build.execution.buildmanager.aspx\"><$c$c>Microsoft.Build.Execution.BuildManager$c$c>和辛格尔顿 Microsoft.Build.Execution.BuildManager.DefaultBuildManager
就是你以后运行构建的任务...来源$ C $ C例子:
Esp. the class Microsoft.Build.Execution.BuildManager
and the Singleton Microsoft.Build.Execution.BuildManager.DefaultBuildManager
is what you are after to run a build task... source code examples:
- http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/ec95c513-f972-45ad-b108-5fcfd27f39bc/
- Logging构建信息与MSBuild的4.0
- http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/ec95c513-f972-45ad-b108-5fcfd27f39bc/
- Logging Build messages with MSBuild 4.0
这篇关于运行编程的MSBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!