Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop checking .ni.dll/exe on Core #6663

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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