使用MSBuild.exe在发布模式下构建C#解决方案

133

我可以使用MSBuild.exe构建解决方案,但我的问题是我只能在DEBUG模式下构建它。我需要使用MSBUILD在Release模式下构建我的解决方案。

以下是我尝试过的方法:

Process msbuild = Process.Start("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MsBuild.exe", solutionfilepath + " /P:Config=Release");

Process msbuild = Process.Start("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MsBuild.exe", solutionfilepath + " /P:Configuration=Release");
1个回答

283
MsBuild.exe [Path to your solution(*.sln)] /t:Build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0

10
为什么要将TargetFramework指定为参数?这应该由解决方案中各个项目进行配置。 - Triynko
5
当项目在不同框架版本的计算机上构建时很有用(仅安装SDK而未安装Visual Studio),在我的情况中v4.7与v4.7.2不兼容。 - weshouman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接