fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
1.99k stars 520 forks source link

Paket does not respect compatible versions of .Net Standard when adding references #4225

Open pastaav opened 9 months ago

pastaav commented 9 months ago

Description

.Net Standard 1.X is possible to compile on later versions of .Net standard like .Net Standard 2.0, but Paket generate conditional loading of assemblys that mean that I on .Net Framework 4.7.2 does not get any assembly loaded at all.

An example would be that System.IO.Compression https://www.nuget.org/packages/System.IO.Compression/#supportedframeworks-body-tab is written for .Net Standard 1.3 and this imply compability with up to .Net Standard 2.1, but Paket give a Project file that ignore to load the assembly unless you explicity target the older versions.

The rules of .Net Standard can be found on https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0

Repro steps

Please provide the steps required to reproduce the problem

  1. Create a solution using .Net Framework 4.7.2

  2. Add reference to System.IO.Compression

  3. Write som code that depend on ZipArchive, but without the assembly loaded the code does not compile

Expected behavior

Paket should generate conditional assembly loading that respect .Net Standard compability guarantees so you can compile the code.

Actual behavior

You get a Project that must target lower version of the standard to compile

Known workarounds

If you manually add an assembly reference to the library, that is basically stop using Paket for Nuget paket, you can compile the code.