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

use*_*000 109 c# msbuild release mode solution

我能够使用MSBuild.exe构建一个解决方案,但我的问题是我只能设法让它在DEBUG模式下构建.我需要使用MSBUILD在Release模式下构建我的解决方案.

这是我尝试过的

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

Process msbuild = Process.Start("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MsBuild.exe", solutionfilepath + " /P:Configuration=Release");
Run Code Online (Sandbox Code Playgroud)

Abd*_*eem 227

MsBuild.exe [Path to your solution(*.sln)] /t:Build /p:Configuration=Release /p:TargetFramework=v4.0
Run Code Online (Sandbox Code Playgroud)

  • 为什么要指定 TargetFramework 作为参数?这应该由解决方案中的各个项目进行配置。 (10认同)
  • @Triynko 当项目在具有不同框架版本的机器上构建时很有用(未安装 Visual Studio,仅安装 SDK),在我的情况下,v4.7 不向后兼容 v4.7.2。 (3认同)