Building C# Solution in Release mode using MSBuild

2019-01-21 11:51发布

问题:

I am able to build a solution using MSBuild.exe, but my issue is I can only manage to get it to build in DEBUG mode. I need to build my solution in Release mode using MSBUILD.

Here is what I've tried

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

and

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

回答1:

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


回答2:

  1. Select Configuration Manager and check parameter such as debug/release or x86/new. 2.Select Release instead of debug from drop down menu near debug button(Visual studio framework).
  2. Click on build and then build yourApplicationName.
  3. Go to your program folder->bin->release->yourApplicationName.exe.
  4. yourApplicationName.exe is ready to use.