Failed build leaves MSBuild processes lying around
See original GitHub issueI have a (closed-source) .NET Core project that uses some custom MSBuild tasks. The tasks are cross-built for both netcoreapp1.1 and .NET Framework 4.6, so that they will work properly in both dotnet build and Visual Studio.
However, when I run the build from within VS and it fails, three or four MSBuild.exe processes remain lying around, holding the DLL containing the tasks open, requiring me to taskkill them before I can replace the DLL with a version containing fixes for debugging. dotnet build does not appear to do this. I am using VS 2017 RC4 build 26206. As far as I can recall, this did not occur on previous builds of VS2017.
Issue Analytics
- State:
 - Created 7 years ago
 - Reactions:2
 - Comments:15 (3 by maintainers)
 
Top Results From Across the Web
Fix intermittent build failures
Learn how to diagnose and fix race conditions in your MSBuild parallel builds.
Read more >The mystery of stuck inactive msbuild.exe processes ...
The 'm' parameter tells msbuild to spawn "nodes", these will remain alive after the build has ended, and are then re-used by new...
Read more >.NET Framework: Build outputs behaving strangely under ...
We've been noticing that after a build is complete, many MSBuild processes remain in a running state. Most of the time, this doesn't...
Read more >How to distribute a .NET Core app in Arch Linux
Looks like the failed builds leave MSBuild processes lying around. How to package the app. We should move all the build output to...
Read more >Dotnet build example. NET CLI, open your favorite terminal i
The dotnet build and msbuild commands are equivalent when passing in a folder profile. ... On the first run, the build process restores...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This feature is called node reuse. You can turn it off on the command-line by running
MSBuild.exe /nodeReuse:false(or just/nr:false). If you want it to not happen in Visual Studio you can set environment variableMSBUILDDISABLENODEREUSE=1. This features (for various reasons) is not supported in the .NET Core version of MSBuild so it will never happen.That being said, the feature is there for performance. Your builds will be quite a bit slower with this turned off. It was added to avoid the overhead of process creation (with many projects and many cores it can be significant) and JIT.
I’m going to close this since it’s by design. Hopefully this answers your question though? If you think there’s really a behavior change between VS2015 and VS2017 feel free to re-open with repro steps. There should be no change.
When will this be fixed on a per project level? This issue is known and was called out since VS2008 every year.
It can’t really be that hard. The MSBuild processes started by Visual Studio are explicitly called WITH then /nodeReuse:true argument.
I’m quite sick and tired of this issue. Had it a few times over the years and every time i look for a solution which doesn’t require me to set a global environment variable does work only for MSBuild from the commandline but not in VS.
Bad, Microsoft, very bad. No, really, very bad.