From ccacf24fb077e9de1f1bfb3af9ad33fb5de71870 Mon Sep 17 00:00:00 2001 From: kkm Date: Thu, 11 Oct 2018 13:12:01 -0700 Subject: Fix dotnet/Mono build and testing under Linux --- .../Grpc.Tools.Tests/Grpc.Tools.Tests.csproj | 49 ++++++++++++++++++---- src/csharp/Grpc.Tools.Tests/NUnitMain.cs | 2 +- .../ProtoCompileCommandLineGeneratorTest.cs | 3 ++ src/csharp/Grpc.Tools/Common.cs | 2 +- src/csharp/Grpc.Tools/Grpc.Tools.csproj | 47 ++++++++++----------- 5 files changed, 66 insertions(+), 37 deletions(-) (limited to 'src/csharp') diff --git a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj index ab14f32afd..70c0474047 100644 --- a/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj +++ b/src/csharp/Grpc.Tools.Tests/Grpc.Tools.Tests.csproj @@ -3,7 +3,7 @@ - net45;netcoreapp1.0 + net45;netcoreapp1.0;netcoreapp2.1 Exe @@ -14,8 +14,8 @@ and may not compile Grpc.Core/Version.cs, as that file references constants in Grpc.Core.dll. TODO(kkm): Refactor imports. --> - - + + /usr/lib/mono/4.5-api /usr/local/lib/mono/4.5-api /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api @@ -27,16 +27,47 @@ - - - - - - + + + + + + + + + + + + + + {HintPathFromItem};{TargetFrameworkDirectory};{RawFileName} + + <_MSBuildAssemblyPath Condition=" '$(MSBuildRuntimeType)' == 'Core' " + >$(FrameworkPathOverride)/../msbuild/$(MSBuildToolsVersion)/bin + + <_MSBuildAssemblyPath Condition=" '$(MSBuildRuntimeType)' != 'Core' " + >$(MSBuildToolsPath) + + diff --git a/src/csharp/Grpc.Tools.Tests/NUnitMain.cs b/src/csharp/Grpc.Tools.Tests/NUnitMain.cs index 5a8ae8cf87..5784cdeac2 100644 --- a/src/csharp/Grpc.Tools.Tests/NUnitMain.cs +++ b/src/csharp/Grpc.Tools.Tests/NUnitMain.cs @@ -22,7 +22,7 @@ using NUnitLite; namespace Grpc.Tools.Tests { static class NUnitMain { public static int Main(string[] args) => -#if NETCOREAPP1_0 +#if NETCOREAPP1_0 || NETCOREAPP1_1 new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args); #else new AutoRun().Execute(args); diff --git a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTest.cs b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTest.cs index c5d43f08d9..06376f8ef4 100644 --- a/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTest.cs +++ b/src/csharp/Grpc.Tools.Tests/ProtoCompileCommandLineGeneratorTest.cs @@ -16,6 +16,7 @@ #endregion +using System.IO; using Microsoft.Build.Framework; using Moq; using NUnit.Framework; @@ -152,6 +153,8 @@ namespace Grpc.Tools.Tests { [TestCase("C:\\" , "C:\\")] [TestCase("C:\\\\" , "C:\\")] public void DirectorySlashTrimmingCases(string given, string expect) { + if (Path.DirectorySeparatorChar == '/') + expect = expect.Replace('\\', '/'); _task.OutputDir = given; ExecuteExpectSuccess(); Assert.That(_task.LastResponseFile, diff --git a/src/csharp/Grpc.Tools/Common.cs b/src/csharp/Grpc.Tools/Common.cs index 1ebd386bd1..9f8600bad0 100644 --- a/src/csharp/Grpc.Tools/Common.cs +++ b/src/csharp/Grpc.Tools/Common.cs @@ -50,7 +50,7 @@ namespace Grpc.Tools { public static bool IsWindows => Os == OsKind.Windows; static Platform() { -#if NETSTANDARD +#if NETCORE Os = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? OsKind.Windows : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? OsKind.Linux : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? OsKind.MacOsX diff --git a/src/csharp/Grpc.Tools/Grpc.Tools.csproj b/src/csharp/Grpc.Tools/Grpc.Tools.csproj index 8edfb848d7..d93947b8ff 100644 --- a/src/csharp/Grpc.Tools/Grpc.Tools.csproj +++ b/src/csharp/Grpc.Tools/Grpc.Tools.csproj @@ -14,8 +14,8 @@ and may not compile Grpc.Core/Version.cs, as that file references constants in Grpc.Core.dll. TODO(kkm): Refactor imports. --> - - + + /usr/lib/mono/4.5-api /usr/local/lib/mono/4.5-api /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api @@ -27,20 +27,16 @@ ../../../third_party/protobuf/src/google/protobuf/ - - + + ../protoc_plugins/protoc_ - + ../protoc_plugins/ - - <_NetStandard>False - <_NetStandard Condition=" $(TargetFramework.StartsWith('netstandard')) or $(TargetFramework.StartsWith('netcore')) ">True - - - $(DefineConstants);NETSTANDARD + + $(DefineConstants);NETCORE @@ -71,29 +67,28 @@ Linux and MacOS. Managed runtime is supplied separately in the Grpc.Core package <_Asset PackagePath="build/native/include/google/protobuf/" Include="@(_ProtoAssetName->'$(Assets_ProtoInclude)%(Identity).proto')" /> - <_Asset PackagePath="build/native/bin/windows/protoc.exe" Include="$(Assets_ProtoCompiler)windows_x86/protoc.exe" /> - <_Asset PackagePath="build/native/bin/linux_x86/protoc" Include="$(Assets_ProtoCompiler)linux_x86/protoc" /> - <_Asset PackagePath="build/native/bin/linux_x64/protoc" Include="$(Assets_ProtoCompiler)linux_x64/protoc" /> - <_Asset PackagePath="build/native/bin/macosx_x86/protoc" Include="$(Assets_ProtoCompiler)macos_x86/protoc" /> - <_Asset PackagePath="build/native/bin/macosx_x64/protoc" Include="$(Assets_ProtoCompiler)macos_x64/protoc" /> + <_Asset PackagePath="build/native/bin/windows/" Include="$(Assets_ProtoCompiler)windows_x86/protoc.exe" /> + <_Asset PackagePath="build/native/bin/linux_x86/" Include="$(Assets_ProtoCompiler)linux_x86/protoc" /> + <_Asset PackagePath="build/native/bin/linux_x64/" Include="$(Assets_ProtoCompiler)linux_x64/protoc" /> + <_Asset PackagePath="build/native/bin/macosx_x86/" Include="$(Assets_ProtoCompiler)macos_x86/protoc" /> + <_Asset PackagePath="build/native/bin/macosx_x64/" Include="$(Assets_ProtoCompiler)macos_x64/protoc" /> - <_Asset PackagePath="build/native/bin/windows/grpc_csharp_plugin.exe" Include="$(Assets_GrpcPlugins)protoc_windows_x86/grpc_csharp_plugin.exe" /> - <_Asset PackagePath="build/native/bin/linux_x86/grpc_csharp_plugin" Include="$(Assets_GrpcPlugins)protoc_linux_x86/grpc_csharp_plugin" /> - <_Asset PackagePath="build/native/bin/linux_x64/grpc_csharp_plugin" Include="$(Assets_GrpcPlugins)protoc_linux_x64/grpc_csharp_plugin" /> - <_Asset PackagePath="build/native/bin/macosx_x86/grpc_csharp_plugin" Include="$(Assets_GrpcPlugins)protoc_macos_x86/grpc_csharp_plugin" /> - <_Asset PackagePath="build/native/bin/macosx_x64/grpc_csharp_plugin" Include="$(Assets_GrpcPlugins)protoc_macos_x64/grpc_csharp_plugin" /> + <_Asset PackagePath="build/native/bin/windows/" Include="$(Assets_GrpcPlugins)protoc_windows_x86/grpc_csharp_plugin.exe" /> + <_Asset PackagePath="build/native/bin/linux_x86/" Include="$(Assets_GrpcPlugins)protoc_linux_x86/grpc_csharp_plugin" /> + <_Asset PackagePath="build/native/bin/linux_x64/" Include="$(Assets_GrpcPlugins)protoc_linux_x64/grpc_csharp_plugin" /> + <_Asset PackagePath="build/native/bin/macosx_x86/" Include="$(Assets_GrpcPlugins)protoc_macos_x86/grpc_csharp_plugin" /> + <_Asset PackagePath="build/native/bin/macosx_x64/" Include="$(Assets_GrpcPlugins)protoc_macos_x64/grpc_csharp_plugin" /> - - - + + - - + + -- cgit v1.2.3