xamarin / urho

Code to integrate with the Urho3D engine
Other
464 stars 122 forks source link

Can not import nuget package into netstandard project #289

Open andrekoehler opened 6 years ago

andrekoehler commented 6 years ago

I get the following error message when trying to import the UrhoSharp nuget package into a netstandard 1.1 library project:

Restoring packages for D:\dev_tests\netStdClassLibrary\netStdClassLibrary\netStdClassLibrary.csproj... Package UrhoSharp 1.5.22 is not compatible with netstandard1.1 (.NETStandard,Version=v1.1). Package UrhoSharp 1.5.22 supports:

  • monoandroid (MonoAndroid,Version=v0.0)
  • net45 (.NETFramework,Version=v4.5)
  • portable-net45+win8 (.NETPortable,Version=v0.0,Profile=Profile7)
  • uap10.0 (UAP,Version=v10.0)
  • xamarinios10 (Xamarin.iOS,Version=v1.0) Package restore failed. Rolling back package changes for 'netStdClassLibrary'. Time Elapsed: 00:00:00.1125180 ========== Finished ==========

According to the docs at https://docs.microsoft.com/en-us/dotnet/standard/net-standard#pcl-compatibility it should be possible to import a PCL with Profile 7 or Profile 111 into a netstandard 1.1 project.

I tested the following cases and it worked (tested on Visual Studio 2017 v15.5):

Both worked with and without package https://www.nuget.org/packages/Microsoft.NETCore.Portable.Compatibility installed.

I see that the PCL profile of Urho was changed from 7 to 111 on February 19, 2016: https://github.com/xamarin/urho/commit/4f66e6eb6d16446e2bc1891fa135ad55ea761e9c#diff-3d2937db6774b770acde584410f65b9b However, this should not make a difference, because both of these profiles are compatible with netstandard 1.1

This change was tagged as _1.2.8, so I tried the nuget package one version before that: 1.1.214, but that also fails:

Restoring packages for D:\dev_tests\netStdClassLibrary\netStdClassLibrary\netStdClassLibrary.csproj... GET https://api.nuget.org/v3-flatcontainer/urhosharp/index.json OK https://api.nuget.org/v3-flatcontainer/urhosharp/index.json 493ms GET https://api.nuget.org/v3-flatcontainer/urhosharp/1.1.214/urhosharp.1.1.214.nupkg OK https://api.nuget.org/v3-flatcontainer/urhosharp/1.1.214/urhosharp.1.1.214.nupkg 436ms Installing UrhoSharp 1.1.214. Package UrhoSharp 1.1.214 is not compatible with netstandard1.1 (.NETStandard,Version=v1.1). Package UrhoSharp 1.1.214 supports:

  • monoandroid (MonoAndroid,Version=v0.0)
  • net45 (.NETFramework,Version=v4.5)
  • portable-net45+win8 (.NETPortable,Version=v0.0,Profile=Profile7)
  • uap10.0 (UAP,Version=v10.0)
  • xamarinios10 (Xamarin.iOS,Version=v1.0) Package restore failed. Rolling back package changes for 'netStdClassLibrary'. Time Elapsed: 00:00:47.4476846 ========== Finished ==========

How can I fix this issue and why did the PCL Profile of the nuget package not change after the csproj file was changed?

andrekoehler commented 6 years ago

The issue above occurs for .net standard 1.1 to 1.6, but if I import the latest UrhoSharp nuget package into a netstandard 2.0 project, it seems to work but generates a warning:

Severity Code Description Project File Line Suppression State Warning NU1701 Package 'UrhoSharp 1.5.22' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. ClassLibrary1 D:\dev_tests\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj 1