question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NuGet library targeting only netstandard2.0 wont install to net461 project

See original GitHub issue

Description

When I’m trying to install a NuGet package that has only the netstandard2.0 folder to a project that targets net461, the package is added to the paket.references, but the reference is not being added in *.csproj.

As net461 should be implementing netstandard2.0 I’d assume to be able to use a library targeting netstandard2.0 without problems.

In my original issue I am in control of the internal NuGet library, so I could make it to target also net461, but ain’t the key idea of the whole netstandard that I don’t have to explicitly define all the targeted platforms?

Repro steps

  1. Get the sample repo https://github.com/Gonnagle/paket-tests/releases/tag/paket-issue-2705-repro (paket pinned to version 5.92.0-beta003)
  2. Run paket add MP3Sharp -p UberLibrary

Expected behavior

Paket adds the library as a reference to the project UberLibrary (import clause to the *.csproj with a condition matching framework net461).

Actual behavior

Result can be seen in this commit: https://github.com/Gonnagle/paket-tests/commit/56ea3dcdede62cca38c8bb5bd49c7d58978f580c

Paket adds the package to paket.dependencies, paket.lock and paket.referencies, but the *.csproj does not update (on some earlier version I think I was able to get the referencies, but with condition matching only netstandard2.0 and thus references were still missing in this project…)

Suggested solution

Update the library to target at least net471.

As @matthid points out the current stand is that first .net version “properly” implementing netstandard2.0 is net471 so upgrading to that is proposed if such packages are needed.

Other known workarounds

  • As a really dirty hack the *.csproj could be changed manually… NuGet also seems to add the reference as expected.
  • Update 2018-07-30: When using the new style csproj this doens’t seem to be an issue (nuget dependencies are handled differently and no longer require changes to csproj in the first place…) (NOTE! Kind of a side effect and might not work on all cases)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
matthidcommented, Sep 2, 2017

See discussion in #2391

0reactions
Gonnaglecommented, Aug 2, 2018

Thanks @matthid. Updated the first post to reflect these conclusions and posted a request for dotnet team to clarify in their documentation that net471 is actually the first framework to fully implement netstandard2.0: https://github.com/dotnet/standard/issues/514#issuecomment-409836573

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing a .NetStandard 2.0 Nuget package into a VS2015 ...
Is there any way to install a NetStandard 2.0 package into my project (without upgrading VS or installing any Net Core targeting packs...
Read more >
Please stop lying about .NET Standard 2.0 support!
In this post I have a bit of a rant about Microsoft's NuGet packages lying about supporting .NET Standard 2.0 when they kinda...
Read more >
Cross-platform targeting for .NET libraries
Targeting .NET or .NET Standard, and successfully compiling your project, doesn't guarantee the library will run successfully on all platforms:.
Read more >
Using .NET Standard with Full Framework .NET - Rick Strahl
Hi, Great post thanks a lot. I have a scenario which I have a .net standard 2.0 library which must also target net461....
Read more >
Target frameworks in SDK-style projects - .NET
When you target a framework in an app or library, you're specifying the set of APIs that you'd like to make available to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found