From 6dbdedd9a0257dfbcdf72891d74e62ffdeb36118 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Thu, 24 Sep 2020 15:49:41 +0200 Subject: [PATCH] Make RIDs for the native dependencies in Grpc.Core arch specific --- .../Grpc.Core.NativeDebug.csproj | 8 ++++---- src/csharp/Grpc.Core/Grpc.Core.csproj | 8 ++++---- src/csharp/Grpc.Core/Internal/NativeExtension.cs | 11 ++++++----- src/csharp/Grpc.Core/build/net45/Grpc.Core.targets | 8 ++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/csharp/Grpc.Core.NativeDebug/Grpc.Core.NativeDebug.csproj b/src/csharp/Grpc.Core.NativeDebug/Grpc.Core.NativeDebug.csproj index be0bd1d2b10..f2b773816a7 100644 --- a/src/csharp/Grpc.Core.NativeDebug/Grpc.Core.NativeDebug.csproj +++ b/src/csharp/Grpc.Core.NativeDebug/Grpc.Core.NativeDebug.csproj @@ -19,19 +19,19 @@ - runtimes/win/native/grpc_csharp_ext.x86.dll + runtimes/win-x86/native/grpc_csharp_ext.x86.dll true - runtimes/win/native/grpc_csharp_ext.x86.pdb + runtimes/win-x86/native/grpc_csharp_ext.x86.pdb true - runtimes/win/native/grpc_csharp_ext.x64.dll + runtimes/win-x64/native/grpc_csharp_ext.x64.dll true - runtimes/win/native/grpc_csharp_ext.x64.pdb + runtimes/win-x64/native/grpc_csharp_ext.x64.pdb true diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 816f9ba68bf..b8f83bed429 100755 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -29,19 +29,19 @@ - runtimes/osx/native/libgrpc_csharp_ext.x64.dylib + runtimes/osx-x64/native/libgrpc_csharp_ext.x64.dylib true - runtimes/linux/native/libgrpc_csharp_ext.x64.so + runtimes/linux-x64/native/libgrpc_csharp_ext.x64.so true - runtimes/win/native/grpc_csharp_ext.x64.dll + runtimes/win-x64/native/grpc_csharp_ext.x64.dll true - runtimes/win/native/grpc_csharp_ext.x86.dll + runtimes/win-x86/native/grpc_csharp_ext.x86.dll true diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs index a1bc15ec107..2a2bea363f9 100644 --- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs +++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs @@ -95,7 +95,7 @@ namespace Grpc.Core.Internal // With dotnet cli project targeting netcoreappX.Y, projects will use Grpc.Core assembly directly in the location where it got restored // by nuget. We locate the native libraries based on known structure of Grpc.Core nuget package. // When "dotnet publish" is used, the runtimes directory is copied next to the published assemblies. - string runtimesDirectory = string.Format("runtimes/{0}/native", GetPlatformString()); + string runtimesDirectory = string.Format("runtimes/{0}/native", GetRuntimeIdString()); var netCorePublishedAppStylePath = Path.Combine(assemblyDirectory, runtimesDirectory, GetNativeLibraryFilename()); var netCoreAppStylePath = Path.Combine(assemblyDirectory, "../..", runtimesDirectory, GetNativeLibraryFilename()); @@ -180,19 +180,20 @@ namespace Grpc.Core.Internal } #endif - private static string GetPlatformString() + private static string GetRuntimeIdString() { + string architecture = GetArchitectureString(); if (PlatformApis.IsWindows) { - return "win"; + return string.Format("win-{0}", architecture); } if (PlatformApis.IsLinux) { - return "linux"; + return string.Format("linux-{0}", architecture); } if (PlatformApis.IsMacOSX) { - return "osx"; + return string.Format("osx-{0}", architecture); } throw new InvalidOperationException("Unsupported platform."); } diff --git a/src/csharp/Grpc.Core/build/net45/Grpc.Core.targets b/src/csharp/Grpc.Core/build/net45/Grpc.Core.targets index e447a2d0150..3f33b9fca9a 100644 --- a/src/csharp/Grpc.Core/build/net45/Grpc.Core.targets +++ b/src/csharp/Grpc.Core/build/net45/Grpc.Core.targets @@ -10,22 +10,22 @@ the Grpc.Core.dll assembly and the native libraries are used at all times. --> - + PreserveNewest grpc_csharp_ext.x86.dll false - + PreserveNewest grpc_csharp_ext.x64.dll false - + PreserveNewest libgrpc_csharp_ext.x64.so false - + PreserveNewest libgrpc_csharp_ext.x64.dylib false