Xamarin-macios: Transitive nuget dependencies are not handled with netstandard libraries

Created on 17 Apr 2018  路  6Comments  路  Source: xamarin/xamarin-macios

A netstandard library that depends on nuget libraries will not be correctly resolved unless the XM or XI library in question also resolves those libraries independently.

Steps to Reproduce

  1. TestNugetProjectOverRefs.zip
  2. Build XM (TestNugetProjectOverRefs) project and run. Note runtime failure
  3. Build XI (TestNugetProjectOverRefs.iOS) project. It will fail in linking.

Expected Behavior

The XI and XM library to resolve the nuget required by the netstd library.

Actual Behavior

The "transitive" dependency of a dependency is not resolved correctly.

Environment

https://gist.github.com/chamons/a1fb655991f9bb749168b406e7544cce

Build Logs

https://gist.github.com/chamons/f66954a712614afa70058b63e909041a

Example Project (If Possible)

enhancement iOS macOS

Most helpful comment

So after some investigation (for a developer community issue), it seems this is kind of the expected behavior: dependencies of .netstandard projects don't flow to the referencing ("old-style") project. This behavior is explained in https://github.com/dotnet/sdk/issues/901.

The fix seems to be to migrate your main project to a PackageReference project, which is fairly simple: https://stackoverflow.com/a/49266856/183422.

For extensions, this also needs an additional fix (the fix for https://github.com/xamarin/xamarin-macios/issues/4237), which should be released to stable together with our iOS 12 supported release fairly soon.

Leaving open so that we can write tests (can't do it quite yet, since we need to build/test with msbuild, which requires 2018-06 to get a version that supports our needs).

All 6 comments

    Dependency "Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed".
        Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

msbuild does not resolve it so it's never given to mmp (or mtouch)

Well then it's an msbuild issue apparently. This "should" work I believe. @jstedfast @radical ?

Any update on this issue?

Should I just add my transitive dependencies as references in my root project as a workaround? Doing this works with my NuGet dependencies.

@chances - I believe that is the best work around until this is sorted out. There is no update currently.

So after some investigation (for a developer community issue), it seems this is kind of the expected behavior: dependencies of .netstandard projects don't flow to the referencing ("old-style") project. This behavior is explained in https://github.com/dotnet/sdk/issues/901.

The fix seems to be to migrate your main project to a PackageReference project, which is fairly simple: https://stackoverflow.com/a/49266856/183422.

For extensions, this also needs an additional fix (the fix for https://github.com/xamarin/xamarin-macios/issues/4237), which should be released to stable together with our iOS 12 supported release fairly soon.

Leaving open so that we can write tests (can't do it quite yet, since we need to build/test with msbuild, which requires 2018-06 to get a version that supports our needs).

So I'm still seeing this problem on resolving native libraries inside nugets.

In this example:

CogServTest.zip

I have two projects:

  • CogServTest - A XI project
  • NetLib - A netstd library

NetLib has a reference to Microsoft.CognitiveServices.Speech nuget. If the XI project does not, it incorrectly resolves:

~/.nuget/packages/microsoft.cognitiveservices.speech/1.13.0/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.core.dll

NOT

~/.nuget/packages/microsoft.cognitiveservices.speech/1.13.0//build/Xamarin.iOS/libMicrosoft.CognitiveServices.Speech.core.a

Once I add the nuget to the main XI project, it starts working.

Was this page helpful?
0 / 5 - 0 ratings