Skip to content

Conversation

@huulinhnguyen-dev
Copy link
Contributor

Fixes #
Change version check from != to < to allow loading newer assembly versions when older versions are requested. #12370

Context

MSBuildLoadContext was using exact version matching (!=) when loading assemblies, preventing version roll-forward. This caused tasks to fail when requesting an older assembly version even though a newer compatible version was available.

Changes Made

  • Changed version comparison in MSBuildLoadContext.cs from != to < (line 86)
  • Added unit test MSBuildLoadContext_AcceptsNewerAssemblyVersions in TaskBuilder_Tests.cs
  • Added test task ValidateAssemblyVersionRollForward in AssemblyLoadContextTestTasks.cs

Testing

  • Added unit test that verifies assembly version roll-forward behavior
  • Test requests System.Collections.Immutable v1.0.0.0 and verifies newer version loads successfully
  • Test only runs on platforms with FEATURE_ASSEMBLYLOADCONTEXT (.NET Core/.NET 5+)

Notes

This change allows MSBuildLoadContext to accept any assembly version >= requested version, matching standard .NET assembly loading behavior.

@huulinhnguyen-dev huulinhnguyen-dev marked this pull request as ready for review December 10, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant