Home > Build, MSBuild > Fix MSBuild 2015 Compile Taking A Very Long Time

Fix MSBuild 2015 Compile Taking A Very Long Time

I created the Invoke-MsBuild PowerShell Module (also available in the PowerShell Gallery), and recently added support to use the Visual Studio 2015 version of MsBuild.exe, when available. After doing so, I noticed that sometimes the build would take a very long time to complete; a solution that typically would take 10 seconds to compile was all of a sudden taking 10 minutes. When changing Invoke-MsBuild back to defaulting to the Visual Studio 2013 version of MsBuild.exe the problem went away. I thought that maybe there was just something strange with my workstation, however after updating Invoke-MsBuild on our build servers at my work we saw the same thing there.

Luckily, a fellow by the name of Jens Doose contacted me saying that he was experiencing the same problem when using Invoke-MsBuild, and also that he had fixed it. The solution ended up being that when calling MsBuild.exe, we had to specify an additional command-line argument of /p:UseSharedConfiguration=false.

msbuild.exe someSolution.sln /p:Configuration=Release /p:UseSharedConfiguration=false

I’m not sure what the other implications of providing this UseSharedConfiguration parameter are as I can’t find any documentation of it online, and I’m not really sure how Jens came across it. It does seem to solve the problem of compiling take a long time though, and I haven’t noticed any other side effects, so I’m going to stick with it.

If you run into the same problem with msbuild.exe and this helps you out, leave a comment to let me know. Happy coding!

  1. Florent
    January 26th, 2017 at 12:19 | #1

    Hello,
    We have the same problem here, this option does fix the problem, on the other side the option : /m:4 /nr:false fix it.
    Source : http://stackoverflow.com/questions/13510465/the-mystery-of-stuck-inactive-msbuild-exe-processes-locked-stylecop-dll-nuget

    Thank you for your Powershell library for MSBuild
    Regards,
    Florent

  1. No trackbacks yet.