MSBUILD:错误MSB1008:只能指定一个项目。开关:工作室

时间:2017-07-12 10:43:39

标签: c#-4.0

private void GetExeFile(string link)
{
    Process compiler = new Process();
    compiler.StartInfo.FileName = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe";
    compiler.StartInfo.Arguments = link + @"‪C:\Users\khan\Documents\Visual Studio 2012\Projects\Calculator\Calculator.sln /t:build /r:System.dll /out:sample.exe stdstr.cs";
    compiler.StartInfo.UseShellExecute = false;
    compiler.StartInfo.RedirectStandardOutput = true;
    compiler.Start();
    txtGetContent.Text = compiler.StandardOutput.ReadToEnd();
    compiler.WaitForExit();

1 个答案:

答案 0 :(得分:3)

您需要引用解决方案文件名,因为它在:

中有空格
compiler.StartInfo.Arguments = link + @"‪""C:\Users\khan\Documents\Visual Studio 2012\Projects\Calculator\Calculator.sln"" /t:build /r:System.dll /out:sample.exe stdstr.cs";

这就是参数解析的工作原理 - 它不是C#特有的。

相关问题