Allow loading MSBuild into separate AssemblyLoadContext
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- build-system, tooling
Research direction
Start by tracing the RegisterMSBuild{xxx}(...) APIs and their use of AssemblyLoadContext.Default. Compare contextual reflection with an overload accepting an AssemblyLoadContext, then investigate how loaded-state tracking, unloading, and process-wide MSBuild environment variables affect multiple instances. Done requires a decided design that supports separate lifetime management without unresolved cross-instance conflicts.
Written by the indexing model from the issue text.
Description
Currently, the MSBuild assemblies are loaded into the default AssemblyLoadContext. However, I'm interested in being able to load it into a seprate one so I can manage its lifetime separately from the rest of the app.
There are two ways I see this can be added:
- Replace the call to
AssemblyLoadContext.Defaultto.CurrentContextualReflectionContext(which will require adding a .NET Core 3.1+ target)
#if NETCOREAPP2_1
AssemblyLoadContext.Default.Resolving += s_registeredHandler;
#else
var alc = AssemblyLoadContext.CurrentContextualReflectionContext ?? AssemblyLoadContext.Default;
alc.Resolving += s_registeredHandler;
#endif
- Add an overload to
RegisterMSBuild{xxx}(...)that takes anAssemblyLoadContext
Problems with this:
- Either way, it will only allow loading it into a single
AssemblyLoadContextand currently wouldn't understand an assembly load context being unloaded - Even if it were allowed in multiple assembly load contexts, .NET SDK msbuild instances register environment variables that will continue to be process wide and would therefor potentially cause conflicts if multiple msbuild instances are loaded at once
The first problem is surmountable by changing how it's tracked that MSBuild is loaded. The second issue is something I don't have an answer for.
- Dominant language
- C#
- Stars
- 262
- Forks
- 91
- Avg merge
- 11d 22h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/MSBuildLocator
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
microsoft/MSBuildLocator#390 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 64/100
microsoft/MSBuildLocator#389 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/MSBuildLocator#380 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoft/MSBuildLocator#377 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/MSBuildLocator#371 · 1 comment ·
All issues in microsoft/MSBuildLocator
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·