[英]Build visual studio solution using msbuild from c# code
I want to build my solution file from other c# code using msbuid I have tried 我想使用我尝试过的msbuid从其他C#代码构建解决方案文件
var msbuild_path = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
var solution_path = @"D:\Sumit\WorkingCopy\Final\Final.sln";
Process.Start(msbuild_path + " " + solution_path);
but this one throws an error Please help me out!! 但这引发了错误,请帮帮我!!
According to https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx , the Process.Start method takes two arguments: 根据https://msdn.microsoft.com/zh-cn/library/h6ak8zt5(v=vs.110).aspx,Process.Start方法采用两个参数:
public static Process Start(string fileName, string arguments)
So you should change your code to 因此,您应该将代码更改为
Process.Start(msbuild_path, solution_path);
What you were doing before was actually trying to run a file named " C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe( space )D:\\Sumit\\WorkingCopy\\Final\\Final.sln ", but no such file exists with that name. 您之前所做的实际上是尝试运行一个名为“ C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ msbuild.exe( space )D:\\ Sumit \\ WorkingCopy \\ Final \\ Final.sln ”的文件,但是没有具有该名称的此类文件。 The msbuild.exe may exist, but " msbuild.exe D:\\Sumit...\\Final.sln " is not the filename you meant to pass as the command filename. msbuild.exe可能存在,但是“ msbuild.exe D:\\ Sumit ... \\ Final.sln ”不是您要作为命令文件名传递的文件名。 Also, the argument string was empty, so the system assumed you did not want to pass any arguments to "msbuild.exe D:\\Sumit...\\Final.sln". 另外,参数字符串为空,因此系统假定您不想将任何参数传递给“ msbuild.exe D:\\ Sumit ... \\ Final.sln”。 But the error message was because the two filenames were mashed into one filename. 但是错误消息是因为两个文件名被合并为一个文件名。
Windows allows filenames to contain embedded spaces, which frequently causes problems in dealing with command-line arguments. Windows允许文件名包含嵌入的空格,这经常导致在处理命令行参数时出现问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.