diff --git a/src/Shared/CoreCLRAssemblyLoader.cs b/src/Shared/CoreCLRAssemblyLoader.cs index 14cd04a244d..19b6d03f5d0 100644 --- a/src/Shared/CoreCLRAssemblyLoader.cs +++ b/src/Shared/CoreCLRAssemblyLoader.cs @@ -153,26 +153,23 @@ private Assembly TryResolveAssemblyFromPaths(AssemblyLoadContext context, Assemb { foreach (var searchPath in searchPaths) { - foreach (var extension in MSBuildLoadContext.Extensions) + var candidatePath = Path.Combine(searchPath, + cultureSubfolder, + $"{assemblyName.Name}.dll"); + + if (IsAssemblyAlreadyLoaded(candidatePath) || + !FileSystems.Default.FileExists(candidatePath)) { - var candidatePath = Path.Combine(searchPath, - cultureSubfolder, - $"{assemblyName.Name}.{extension}"); - - if (IsAssemblyAlreadyLoaded(candidatePath) || - !FileSystems.Default.FileExists(candidatePath)) - { - continue; - } - - AssemblyName candidateAssemblyName = AssemblyLoadContext.GetAssemblyName(candidatePath); - if (candidateAssemblyName.Version != assemblyName.Version) - { - continue; - } - - return LoadAndCache(context, candidatePath); + continue; } + + AssemblyName candidateAssemblyName = AssemblyLoadContext.GetAssemblyName(candidatePath); + if (candidateAssemblyName.Version != assemblyName.Version) + { + continue; + } + + return LoadAndCache(context, candidatePath); } } diff --git a/src/Shared/MSBuildLoadContext.cs b/src/Shared/MSBuildLoadContext.cs index f080c2e05a9..4ffa7f5b04a 100644 --- a/src/Shared/MSBuildLoadContext.cs +++ b/src/Shared/MSBuildLoadContext.cs @@ -29,9 +29,6 @@ internal class MSBuildLoadContext : AssemblyLoadContext "Microsoft.Build.Utilities.Core", }.ToImmutableHashSet(); - internal static readonly string[] Extensions = new[] { "ni.dll", "ni.exe", "dll", "exe" }; - - public MSBuildLoadContext(string assemblyPath) : base($"MSBuild plugin {assemblyPath}") { @@ -56,11 +53,9 @@ public MSBuildLoadContext(string assemblyPath) // bare search directory if that fails. : new[] { assemblyName.CultureName, string.Empty }) { - foreach (var extension in Extensions) - { var candidatePath = Path.Combine(_directory, cultureSubfolder, - $"{assemblyName.Name}.{extension}"); + $"{assemblyName.Name}.dll"); if (!FileSystems.Default.FileExists(candidatePath)) { @@ -74,7 +69,6 @@ public MSBuildLoadContext(string assemblyPath) } return LoadFromAssemblyPath(candidatePath); - } } // If the Assembly is provided via a file path, the following rules are used to load the assembly: