Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8e22fe1

Browse filesBrowse files
authored
Use RuntimeInformation to determine the Processor architecture. (#108)
See https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.architecture?view=net-6.0 Now that we ship an arm based native library on windows we need to be able to determine the underlying library to load. We can use the `RuntimeInformation.ProcessArchitecture` value to get this data. Then based on that we can load from `x86`, `x64` or `arm64` subdirectories. Note we will still fallback to loading from the current directory , but the preference is to load from on of the architecture specific sub directories.
1 parent 33f5b01 commit 8e22fe1
Copy full SHA for 8e22fe1

File tree

Expand file treeCollapse file tree

2 files changed

+14
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-4
lines changed
Open diff view settings
Collapse file

‎LibZipSharp/Xamarin.LibZipSharp.targets‎

Copy file name to clipboardExpand all lines: LibZipSharp/Xamarin.LibZipSharp.targets
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\libZipSharpNative.*">
7-
<Link>lib64\%(FileName)%(Extension)</Link>
7+
<Link>x64\%(FileName)%(Extension)</Link>
88
</_LibZipNativeLibs>
99
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\native\libZipSharpNative.*">
10-
<Link>%(FileName)%(Extension)</Link>
10+
<Link>arm64\%(FileName)%(Extension)</Link>
1111
</_LibZipNativeLibs>
1212
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\libZipSharpNative.*">
13-
<Link>%(FileName)%(Extension)</Link>
13+
<Link>x86\%(FileName)%(Extension)</Link>
1414
</_LibZipNativeLibs>
1515
<_LibZipNativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\osx\native\libZipSharpNative.dylib">
1616
<Link>%(FileName)%(Extension)</Link>
Collapse file

‎LibZipSharp/Xamarin.Tools.Zip/Native.cs‎

Copy file name to clipboardExpand all lines: LibZipSharp/Xamarin.Tools.Zip/Native.cs
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,17 @@ static Native ()
455455
{
456456
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
457457
string executingDirectory = System.IO.Path.GetDirectoryName (typeof(Native).Assembly.Location);
458-
SetDllDirectory (Environment.Is64BitProcess ? System.IO.Path.Combine (executingDirectory, "lib64") : executingDirectory);
458+
#if !NET45
459+
string arch = RuntimeInformation.ProcessArchitecture.ToString ().ToLower ();
460+
string path = System.IO.Path.Combine (executingDirectory, arch);
461+
#else
462+
string path = System.IO.Path.Combine (executingDirectory, Environment.Is64BitProcess ? "x64" : "x86");
463+
#endif
464+
if (System.IO.Directory.Exists (path)) {
465+
SetDllDirectory (path);
466+
return;
467+
}
468+
SetDllDirectory (executingDirectory);
459469
}
460470
}
461471
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.