Skip to content

Conversation

@huulinhnguyen-dev
Copy link
Contributor

Fixes #
Fix the issue: Could not load file or assembly Microsoft.DotNet.MsBuildSdkResolver #12578

Context

External API users were experiencing failures when loading Microsoft.DotNet.MSBuildSdkResolver because Assembly.Load with CodeBase was failing. This caused SDK resolution to fail for external tools and applications.

Changes Made

  • Modified LoadResolverAssembly in SdkResolverLoader to add fallback behavior for external API users
  • External API users now fallback from Assembly.Load to Assembly.LoadFrom when Assembly.Load fails
  • Added unit tests to verify both fallback and no-fallback scenarios

Testing

  • Added LoadResolverAssembly_MSBuildSdkResolver_ExternalAPIUser_FallbackSucceeds test to verify external API users get successful fallback
  • Added LoadResolverAssembly_MSBuildSdkResolver_VisualStudioUser_NoFallback test to verify VS users don't get fallback
  • Tests use TestableSdkResolverLoader to control RunningInVisualStudio environment and test path

Notes

This change improves compatibility for external API users while maintaining the existing behavior for Visual Studio users. The fallback ensures that SDK resolution works in more scenarios without breaking VS functionality.

@huulinhnguyen-dev huulinhnguyen-dev force-pushed the dev/huulinhnguyen/fail-to-resolve-MsBuildSdkResolver branch from d09e1d3 to 50d9905 Compare November 4, 2025 06:38
@huulinhnguyen-dev huulinhnguyen-dev force-pushed the dev/huulinhnguyen/fail-to-resolve-MsBuildSdkResolver branch from 6d951d8 to 8a4c5dd Compare November 5, 2025 05:32
@huulinhnguyen-dev huulinhnguyen-dev force-pushed the dev/huulinhnguyen/fail-to-resolve-MsBuildSdkResolver branch from a3ff673 to ec2dca6 Compare November 5, 2025 08:06
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.

2 participants