简体   繁体   English

使用C#代码中的msbuild构建Visual Studio解决方案

[英]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.

相关问题 使用 c#、visual studio 和 msbuild 编辑解决方案 - editing a solution with c#, visual studio and msbuild 使用MSBuild时,Visual Studio Android解决方案在遇到C#版本冲突时停止构建 - Visual Studio Android solution stops building upon hitting C# version conflict when using MSBuild 从代码构建visual studio解决方案 - Build visual studio solution from code Visual Studio 2012 C#解决方案,并行构建竞争条件 - Visual Studio 2012 C# solution, parallel build race condition 使用C#和Powershell项目构建Visual Studio解决方案 - Build a Visual Studio Solution with C# AND Powershell projects vs2003:C#无法建立Visual Studio解决方案 - vs2003 : c# can not build visual studio solution 如何从C#项目的构建事件中访问Visual Studio解决方案级平台? - How can you access the Visual Studio solution level platform from a C# project's build event? 使用MSBuild通过InstallShield Pro Project生成Visual Studio解决方案时缺少DLL和自定义操作 - Missing DLL's and Custom Actions when using MSBuild to build Visual Studio Solution with InstallShield Pro Project 当我尝试使用 MSBuild 构建我的解决方案时,它会启动 Visual Studio - When I tried to build my solution using MSBuild, its launches Visual Studio 从 msbuild 构建解决方案时未构建 Visual Studio 项目 - Visual Studio project not being built when I build Solution from msbuild
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM