Summary
When MSBuild Server (and to a lesser degree Multithreaded MSBuild) is enabled, Tasks that depend on static singletons may exhibit behavior that violates some of the invariants of those modes - an example of this is the NuGet PluginManager, or the EnvironmentWrapper, both of which are static singletons that would remain alive for longer durations than expected.
Background and Motivation
These statics can leak data across builds, or simply cache data for a duration not expected by the Task authors, and implicitly violate the lifetime expectations of the MSBuild Server node/Multithreaded build nodes.
Proposed Feature
We need to provide guidance for Task authors about what the proper use of statics is, and how to ensure that these are cleaned up/re-initialized/etc at appropriate lifecycle points for the MSBuild Server/Multithreaded lifecycles.
We also need to expose additional MSBuild flags/properties for:
- is the build multithreaded
- is the build server mode
because in both of these cases, the central scheduler node is also a worker node, so for Tasks like RestoreTask that operate on the central node always, they will persist. To fix this, in either MT or Server, the Task needs a UsingTask change to kick out to a TaskHost.
Alternative Designs
No response
Summary
When MSBuild Server (and to a lesser degree Multithreaded MSBuild) is enabled, Tasks that depend on static singletons may exhibit behavior that violates some of the invariants of those modes - an example of this is the NuGet PluginManager, or the EnvironmentWrapper, both of which are static singletons that would remain alive for longer durations than expected.
Background and Motivation
These statics can leak data across builds, or simply cache data for a duration not expected by the Task authors, and implicitly violate the lifetime expectations of the MSBuild Server node/Multithreaded build nodes.
Proposed Feature
We need to provide guidance for Task authors about what the proper use of statics is, and how to ensure that these are cleaned up/re-initialized/etc at appropriate lifecycle points for the MSBuild Server/Multithreaded lifecycles.
We also need to expose additional MSBuild flags/properties for:
because in both of these cases, the central scheduler node is also a worker node, so for Tasks like RestoreTask that operate on the central node always, they will persist. To fix this, in either MT or Server, the Task needs a UsingTask change to kick out to a TaskHost.
Alternative Designs
No response