I'm using a NuGet package which contains the assemblies for 2 target frameworks: net45 and netstandard1.5
My project is targeting net471 (so compatible with netstandard1.5). When I add the package, it copies the dll from net45 folder. How to force NuGet to use the dll from the standard folder?
The problem with the net45 version is that it needs an older version of a dependency package, the standard dll has no dependency.
You can download the . nupkg file (https://www.nuget.org/packages > Download ) then unzip it. In the file you can find references to PlatformToolset, ToolsVersion which I was able to use to look up the specific version of the compiler.
The target framework moniker (TFM) to apply when installing the package. This is initially set to the project's target when a package is installed. As a result, different <package> elements can have different TFMs. For example, if you create a project targeting .
How to choose target framework from Nuget package
According to the official document Matching assembly versions and the target framework in a project:
When NuGet installs a package that has multiple assembly versions, it tries to match the framework name of the assembly with the target framework of the project.
So, just as Matt said: "NuGet will use the assembly that is the closest match. More specific target framework wins.", NuGet will install the .net framework assembly to your .net framework project.
To resolve this issue, you can use Matt suggestion, directly reference the .NET Standard assembly yourself in the project or you can download that nuget package manually, set it to the local feed, open it with NuGet Package Explorer, delete the folder net45
under the lib
folder, install that package from local feed, then nuget will use the dll from the standard folder.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With