-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
.NET CoreArea: EngineIssues impacting the core execution of targets and tasks.Issues impacting the core execution of targets and tasks.triaged
Description
MSBuild has several explicit references to AssemblyLoadContext.Default. That prevents an application from using the MSBuild API in a disposable (or otherwise managed) context.
| return AssemblyLoadContext.Default.LoadFromAssemblyPath(_taskAssemblyFile); |
msbuild/src/Shared/MSBuildLoadContext.cs
Lines 82 to 85 in 414393f
| if (FileSystems.Default.FileExists(assemblyNameInExecutableDirectory)) | |
| { | |
| return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyNameInExecutableDirectory); | |
| } |
This one is potentially OK since it's only to support an escape-hatch feature, but we can also consider removing it:
msbuild/src/Shared/CoreCLRAssemblyLoader.cs
Lines 65 to 83 in 414393f
| private Assembly LoadUsingLegacyDefaultContext(string fullPath) | |
| { | |
| lock (_guard) | |
| { | |
| if (!_resolvingHandlerHookedUp) | |
| { | |
| AssemblyLoadContext.Default.Resolving += TryResolveAssembly; | |
| _resolvingHandlerHookedUp = true; | |
| } | |
| Assembly assembly; | |
| if (_pathsToAssemblies.TryGetValue(fullPath, out assembly)) | |
| { | |
| return assembly; | |
| } | |
| return LoadAndCache(AssemblyLoadContext.Default, fullPath); | |
| } | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
.NET CoreArea: EngineIssues impacting the core execution of targets and tasks.Issues impacting the core execution of targets and tasks.triaged