Skip to content

Commit b86d6ba

Browse files
nagilsondsplaisted
authored andcommitted
Skip extra hostfxr logic
What we were doing was setting the AppContext data such that the HOSTFXR_PATH pointed to the installed root location. We don't need to do that, the hostfxr interop(ped) API already points to the dotnet root location within which we want to resolve the hostfxr.
1 parent bc57e9f commit b86d6ba

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

src/Installer/dnup/ArchiveInstallationValidator.cs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ private bool ValidateWithHostFxr(string installRoot, ReleaseVersion resolvedVers
7575
{
7676
try
7777
{
78-
ConfigureHostFxrResolution(installRoot);
79-
8078
var bundleProvider = new NETBundlesNativeWrapper();
81-
NetEnvironmentInfo environmentInfo = bundleProvider.GetDotnetEnvironmentInfo(installRoot);
79+
NetEnvironmentInfo environmentInfo = bundleProvider.GetDotnetEnvironmentInfo(installRoot); // Could we use get_available_sdks instead to improve perf?
8280

8381
if (component == InstallComponent.SDK)
8482
{
@@ -104,42 +102,4 @@ private bool ValidateWithHostFxr(string installRoot, ReleaseVersion resolvedVers
104102
return false;
105103
}
106104
}
107-
108-
private static void ConfigureHostFxrResolution(string installRoot)
109-
{
110-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
111-
{
112-
return;
113-
}
114-
115-
if (AppContext.GetData(HostFxrRuntimeProperty) is not null)
116-
{
117-
return;
118-
}
119-
120-
string? hostFxrPath = FindHostFxrLibrary(installRoot);
121-
if (hostFxrPath is not null)
122-
{
123-
AppContext.SetData(HostFxrRuntimeProperty, hostFxrPath);
124-
}
125-
}
126-
127-
private static string? FindHostFxrLibrary(string installRoot)
128-
{
129-
string hostFxrDirectory = Path.Combine(installRoot, "host", "fxr");
130-
if (!Directory.Exists(hostFxrDirectory))
131-
{
132-
return null;
133-
}
134-
135-
string libraryName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
136-
? "hostfxr.dll"
137-
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
138-
? "libhostfxr.dylib"
139-
: "libhostfxr.so";
140-
141-
return Directory.EnumerateFiles(hostFxrDirectory, libraryName, SearchOption.AllDirectories)
142-
.OrderByDescending(File.GetLastWriteTimeUtc)
143-
.FirstOrDefault();
144-
}
145105
}

0 commit comments

Comments
 (0)