performancevisual-studio-2015msbuildc#-6.0msbuild-4.0

MSBUILD.exe is executing very slow


Experiencing, MSBUILD.exe is taking very long time.

This command is taking 50+ min to execute: C:\Program Files (x86)\MSBuild\14.0\Bin\amd64>MSBUILD C:\xyz.sln /p:Configuration=Release /p:OutDir=c:/test

This command is taking 1 min to execute: C:\Program Files (x86)\MSBuild\14.0\Bin\amd64>MSBUILD C:\xyz.sln /p:Config=Release /p:OutDir=c:/test

Question:

1: Is that ok to use /p:Config=Release instead of /p:Configuration=Release?

2: What can be the root cause to making the build so long with /p:Configuration=Release?


Solution

  • 1: Is that ok to use /p:Config=Release instead of /p:Configuration=Release?

    I am afraid is not. Just as Lex comment, /p:Config=Release is not a valid argument. I have create a test sample with that argument, but I found that solution is build with default configuration Debug:

    enter image description here

    So the argument /p:Config=Release is a invalid.

    What can be the root cause to making the build so long with /p:Configuration=Release?

    As test above, when you build with /p:Config=Release, VS/MSBuild will build solution with default configuration Debug. As we know, Debug mode does a lot less optimizations, as those can mess up the mapping between instructions and lines of code. So, the compiler is doing less work there. Even if a full debug build is slower, Debug builds happen a lot more often and can usually take advantage of incremental builds a lot more than Release build can. So fairly often a Debug build doesn't have to do nearly as much work as a Release build would. So the command with Debug configuration will take less build time.

    Besides, when you first completed the build solution, you should clean the solution, otherwise, most of projects in the solution will skip building. Because most of them are up-to-date. So you should clean the solution after you build the solution first time.

    In addition, if you want to know the detail info about build process, you can set the "Logging Verbosity" to the value Diagnostic by addding /v:diag to your build command line:

    MSBUILD C:\xyz.sln /p:Configuration=Release /p:OutDir=c:/test /v:diag
    

    enter image description here