Is there a way to unload custom MSBuild task from MSBuild process?



I have my custom MSBuild task with dependencies in the same folder
(other .NET assemblies from NuGet which i copy to separate folder with my task, as MSBuild can’t find references in other places like NuGet packages cache, so i use @(ReferencePathWithRefAssemblies) to get all project references, as my task is NuGet package other references will be installed by NuGet automatically).
The problem is that i need to clean this folder, and then copy references again from build to build to ensure that all NuGet references are there before loading task(), but once my task loaded, MSBuild holds files locks so i can’t clean this folder up.
By stopping all MSBuild.exe processes i can release all locks and folder cleaning goes well.
So might be there is some way to instruct the MSBuild to unload my task and all dependent assemblies after build has finished?


Looks like the only solution for now is to set environment variable MSBUILDDISABLENODEREUSE to 1, so that instructs MSBuild to kill all nodes after build has completed, so the locks are not held anymore. Implemented that with custom .dll task.

Answered By – Snoopy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More