Fix assembly resolution for .exe files and legacy .NET Framework tasks (CLR35 and CLR2)#12823
Merged
YuliiaKovalova merged 7 commits intomainfrom Dec 10, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a long-standing bug in assembly resolution for custom tasks executed out-of-process. The issue was that executables (.exe files) were not being included when gathering assemblies for the MetadataLoadContext resolver, causing dependency resolution failures when tasks or their dependencies were packaged as executables. Additionally, the PR enhances runtime assembly discovery on .NET Framework by including assemblies from v2.0 and v3.5 framework directories.
Key Changes
- Enhanced
TypeLoader.findRuntimeAssembliesWithMicrosoftBuildFramework()to include .NET Framework v2.0 and v3.5 assemblies on .NET Framework builds - Fixed
LoadAssemblyUsingMetadataLoadContext()to enumerate both .dll and .exe files as valid managed assemblies - Added
FrameworkLocationHelper.csto the MSBuild project to support framework path resolution
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Shared/TypeLoader.cs | Added .NET Framework v2.0/v3.5 assembly discovery and fixed assembly enumeration to include .exe files alongside .dll files |
| src/MSBuild/MSBuild.csproj | Included FrameworkLocationHelper.cs shared file to enable framework path lookups |
Co-authored-by: Copilot <[email protected]>
10e8cf5 to
89fdbf1
Compare
SimaTian
approved these changes
Dec 10, 2025
This was referenced Dec 11, 2025
rainersigwald
added a commit
to rainersigwald/msbuild
that referenced
this pull request
Dec 15, 2025
…work tasks (CLR35 and CLR2) (dotnet#12823)" This reverts commit 2960e90.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The recent change #12642 helped to uncover a long-term bug when a custom task was eventually executed out-of-proc, but due to lack of architecture/runtime match check BEFORE the TypeLoad, it was lazily loaded in-proc and pushed out-of-proc later.
msbuild/src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs
Line 335 in ee6457a
look at
!TaskHostParametersMatchCurrentProcessChanges Made
Fixed assembly enumeration: Previously only
.dllfiles were added to MetadataLoadContext's resolver. Now.exefiles are also included, since executables can be valid managed assemblies and dependencies.Added legacy .NET Framework support (.NET Framework only): Added assembly discovery for v2.0 and v3.5 framework directories to support tasks that depend on legacy Microsoft.Build.Utilities.dll (as opposed to the modern Microsoft.Build.Utilities.Core.dll).
Test
Locally tested with custom tasks using both modern and legacy MSBuild assemblies + current tests confirm there are no regression.