Building C# Solution in Release mode using MSBuild.exe

102,012
MsBuild.exe [Path to your solution(*.sln)] /t:Build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0
Share:
102,012
user3682000
Author by

user3682000

Updated on October 20, 2020

Comments

  • user3682000
    user3682000 over 3 years

    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");
    
  • Triynko
    Triynko almost 5 years
    Why would you specify a TargetFramework as a parameter? That's supposed to be configured by the individual projects within the solution.
  • weshouman
    weshouman over 3 years
    @Triynko Useful when the project is being built in machines with different framework versions (visual studio not installed, only the SDK), v4.7 was not backward compatible with v4.7.2 in my case.