Skip to content

Commit

Permalink
Merge pull request #6663 from rainersigwald/no-ni-on-core
Browse files Browse the repository at this point in the history
Stop checking .ni.dll/exe on Core
  • Loading branch information
ladipro authored Jul 28, 2021
2 parents 2579961 + ab9e654 commit 9f91131
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
33 changes: 15 additions & 18 deletions src/Shared/CoreCLRAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/Shared/MSBuildLoadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
{
Expand All @@ -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))
{
Expand All @@ -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:
Expand Down

0 comments on commit 9f91131

Please sign in to comment.