NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

portable-net40 being picked when a portable-net45 option is available when using imports #2453

Closed livarcocc closed 8 years ago

livarcocc commented 8 years ago

Repro at this branch: https://github.com/livarcocc/nuget_repro.

Just run:

dotnet restore --infer-runtimes dotnet test

Result:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.Extensions.DependencyModel.DependencyContextJsonReader.Read(Stream stream)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadAssemblyContext(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
   at Xunit.Runner.DotNet.Program.GetAvailableRunnerReporters()
   at Xunit.Runner.DotNet.Program.Run(String[] args)
   at Xunit.Runner.DotNet.Program.Main(String[] args)

Expected:

Tests to run successfully.

This fails because newtonsoft.json has the below and nuget is picking portable-net40 instead of the better one which is portable-net50

"Newtonsoft.Json/7.0.1": {
      "sha512": "q3V4KLetMLnt1gpAVWgtXnHjKs0UG/RalBc29u2ZKxd5t5Ze4JBL5WiiYIklJyK/5CRiIiNwigVQUo0FgbsuWA==",
      "type": "package",
      "files": [
        "Newtonsoft.Json.7.0.1.nupkg.sha512",
        "Newtonsoft.Json.nuspec",
        "lib/net20/Newtonsoft.Json.dll",
        "lib/net20/Newtonsoft.Json.xml",
        "lib/net35/Newtonsoft.Json.dll",
        "lib/net35/Newtonsoft.Json.xml",
        "lib/net40/Newtonsoft.Json.dll",
        "lib/net40/Newtonsoft.Json.xml",
        "lib/net45/Newtonsoft.Json.dll",
        "lib/net45/Newtonsoft.Json.xml",
        "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
        "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
        "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll",
        "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml",
        "tools/install.ps1"
      ]
    }

cc @ericstj

emgarten commented 8 years ago

This is a known issue that is caused by an invalid framework portable-net45+wp80+win8+wpa81+dnxcore50 in the newtonsoft.json package. NuGet will favor valid frameworks, in this case that is portable-net40+sl5+wp80+win8+wpa81.

You can work around this by adding dnxcore50 as your first import.