Skip to content

work in progress fix for #7230#7295

Closed
jtattermusch wants to merge 11 commits intogrpc:masterfrom
jtattermusch:csharp_dotnet_cli_net45
Closed

work in progress fix for #7230#7295
jtattermusch wants to merge 11 commits intogrpc:masterfrom
jtattermusch:csharp_dotnet_cli_net45

Conversation

@jtattermusch
Copy link
Copy Markdown
Contributor

@jtattermusch jtattermusch commented Jul 9, 2016

Some experiments toward making Grpc.Core nuget work with dotnet cli project targeting net45.

-- I don't like adding Microsoft.NETCore.Platforms dependency, but it doesn't work without it.
-- we can get rid of duplicate of native grpc_csharp_ext library by changing more of NativeExtension.cs code.

One problem is that on macOS X, it seems that the /runtimes nuget functionality doesn't work very well because:
On my machine, despite having a 32-bit version of mono, dotnet build copies a 64bit version of libgrpc_csharp_ext.dylib to the output directory and then mono is used to run it - which results in error loading the native library (can't load 64bit library into 32bit process).

[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Error loading native library "/Users/jtattermusch/experiments/grpc_dotnet_cli/bin/Release/net45/osx.10.11-x64/libgrpc_csharp_ext.dylib"
  at Grpc.Core.Internal.UnmanagedLibrary..ctor (System.String[] libraryPathAlternatives) <0x7809f0 + 0x00103> in <filename unknown>:0 

@jtattermusch
Copy link
Copy Markdown
Contributor Author

(also, this attempts to fix the nugets generated by "dotnet pack" - which is not yet the official way of generating nugets for gRPC. Analogous steps are needed to fix the old .nuspec based nugets).

@jtattermusch
Copy link
Copy Markdown
Contributor Author

Pushed 2 more commits with a fix for the mono 32bit vs 64bit version problem described above.

@jskeet
Copy link
Copy Markdown
Contributor

jskeet commented Jul 9, 2016

Not quite sure how this PR relates to my one at #7282. That has a significant set of changes for getting it working on Windows which I don't believe are in this PR.

I don't think Grpc.Core itself should have the Microsoft.NETCore.Platforms dependency, because we don't want it pulled in for users using csproj files. It's just a final application-user dependency. Admittedly if we could make it so the end user didn't need to know about it, that would be better... we should see what that dependency does on non-dotnet-cli environments.

I suspect your issue running on OSX between 32-bit and 64-bit is related to the one I've been encountering trying to run the 32-bit CLR on Windows; I believe the tooling for dotnet run just doesn't take note of the architecture properly. If you run dotnet build -a x86 does that help? I'd expect that to copy the right file into the output directory. (That much works for me on Windows, but running it doesn't - it still uses the x64 CLR.)

@jtattermusch
Copy link
Copy Markdown
Contributor Author

Retiring this PR in favor of #7282.

@jtattermusch
Copy link
Copy Markdown
Contributor Author

On Fri, Jul 8, 2016 at 11:43 PM, Jon Skeet [email protected] wrote:

Not quite sure how this PR relates to my one at #7282
#7282. That has a significant set of
changes for getting it working on Windows which I don't believe are in this
PR.

yes, windows tests are actually broken in my PR. Your fix seems reasonable.

I don't think Grpc.Core itself should have the
Microsoft.NETCore.Platforms dependency, because we don't want it pulled
in for users using csproj files. It's just a final application-user
dependency. Admittedly if we could make it so the end user didn't need to
know about it, that would be better... we should see what that dependency
does on non-dotnet-cli environments.

I added dependency on Microsoft.NETCore.Platforms, because that's what
"libuv" nuget package does. Also, the neat trick they are using it that the
Microsoft.NETCore.Platforms dependency is specified for targetPlatform
"netstandard1.0" so if you have older version of nuget, the dependency is
just ignored. If you have a net45 project depending on libuv, the
dependency is resolved correctly. Unfortunately, because we target net45
and netstandard1.5 separately, that trick probably won't work for us.

I suspect your issue running on OSX between 32-bit and 64-bit is related
to the one I've been encountering trying to run the 32-bit CLR on Windows;
I believe the tooling for dotnet run just doesn't take note of the
architecture properly. If you run dotnet build -a x86 does that help? I'd
expect that to copy the right file into the output directory. (That
much works for me on Windows, but running it doesn't - it still uses the
x64 CLR.)

A quick fix is I make Microsoft.NETCore.Platforms copy both x86 and x64
libraries by adding them under /runtimes/osx (and the right variant is
chosen by gRPC loader code at runtime). Making that change to your PR would
be good I think.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#7295 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AJeq5Mj2JY30jZiecjw6lyp_79rtGSrkks5qT0MYgaJpZM4JIhuB
.

@jskeet
Copy link
Copy Markdown
Contributor

jskeet commented Jul 11, 2016

I added dependency on Microsoft.NETCore.Platforms, because that's what
"libuv" nuget package does.

Mmm. Microsoft.Dia.SymReader.Native doesn't though. I shall see if I can get a question into the community standup.

A quick fix is I make Microsoft.NETCore.Platforms copy both x86 and x64
libraries by adding them under /runtimes/osx

Yes, that would be simple. I'll do that across the board for the moment.

@nathanielmanistaatgoogle nathanielmanistaatgoogle added this to the Someday... milestone Jul 13, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants