Skip to content

Commit 174a10d

Browse files
committed
Try to fix hostfxr loading on non-Windows
1 parent 2c49afa commit 174a10d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Resolvers/Microsoft.DotNet.NativeWrapper/NETBundlesNativeWrapper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ private void PreloadHostFxrLibrary(string dotnetExeDirectory)
3333
string? hostFxrPath = FindHostFxrLibrary(dotnetExeDirectory);
3434
if (hostFxrPath != null)
3535
{
36-
LoadLibraryExW(hostFxrPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH);
36+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
37+
{
38+
LoadLibraryExW(hostFxrPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH);
39+
}
40+
#if NETCOREAPP
41+
else
42+
{
43+
AppContext.SetData(Constants.RuntimeProperty.HostFxrPath, hostFxrPath);
44+
}
45+
#endif
3746
}
3847
}
3948

0 commit comments

Comments
 (0)