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");
0

1 Answer 1

283
MsBuild.exe [Path to your solution(*.sln)] /t:Build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0
2
  • 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, 2019 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, 2020 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.