133

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");
wonea
  • 4,783
  • 17
  • 86
  • 139
user3682000
  • 1,371
  • 2
  • 8
  • 4

1 Answers1

283
MsBuild.exe [Path to your solution(*.sln)] /t:Build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0
weshouman
  • 632
  • 9
  • 17
Abdullah Saleem
  • 3,701
  • 1
  • 19
  • 30
  • 10
    Why would you specify a TargetFramework as a parameter? That's supposed to be configured by the individual projects within the solution. – Triynko Sep 19 '19 at 20:33
  • 5
    @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. – weshouman Oct 20 '20 at 05:23