Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock file contains netcoreapp1.1 dependencies instead of netstandard2.0 #3732

Closed
kerams opened this issue Nov 23, 2019 · 20 comments
Closed

Lock file contains netcoreapp1.1 dependencies instead of netstandard2.0 #3732

kerams opened this issue Nov 23, 2019 · 20 comments

Comments

@kerams
Copy link
Contributor

kerams commented Nov 23, 2019

Description

Adding https://www.nuget.org/packages/Serilog.Sinks.Console/4.0.0-dev-00834 to a .NET Core 3.0 project does not reference the package's netstandard2.0 dependencies (as listed on Nuget) in the lock file but instead netcoreapp1.1

Repro steps

Clone https://github.com/kerams/rep, remove the lock file and do paket install.

Expected behavior

Serilog.Sinks.Console (4.0.0-dev-00834)
      Serilog (>= 2.8)

in the lock file.

Actual behavior

vivaldi_o7hRdYaarF

@matthid
Copy link
Member

matthid commented Nov 23, 2019

Why do you think we should prefer netstandard 2.0 here?
Can you point to the spec or NuGet behavior that would indicate otherwise?
Without looking up anything I'd say this is by design because usually you prefer 'the same framework' so netcoreapp1.1 is closer to netcoreapp3.0 than netstandard2.0.

@kerams
Copy link
Contributor Author

kerams commented Nov 23, 2019

Simply because I thought the goal was to prefer the implementation/standard with the largest API surface (thus requiring the fewest dependencies) while still being supported by the target framework. The highest .NET Standard version netcoreapp1.1 supports is 1.6, whose API surface, I assume, is a strict subset of netstandard2.0's. Therefore choosing the latter should be perfectly safe and could potentially result in a simpler lock file (as is the case above).

@forki
Copy link
Member

forki commented Nov 23, 2019 via email

@kerams
Copy link
Contributor Author

kerams commented Nov 23, 2019

https://github.com/dotnet/standard/blob/master/docs/metaphor.md

Logically, every version of .NET Standard is an interface. Later versions extend the previous version, i.e. there are no breaking changes. Newer versions have all APIs that previous versions had:

@forki
Copy link
Member

forki commented Nov 23, 2019 via email

@kerams
Copy link
Contributor Author

kerams commented Nov 23, 2019

https://github.com/dotnet/standard/blob/master/docs/faq.md

Based on community feedback, we decided not to make .NET Standard 2.0 be a breaking change from 1.x. Instead, .NET Standard 2.0 is a strict superset of .NET Standard 1.6.

It looks pretty unambiguous to me :)

@forki
Copy link
Member

forki commented Nov 23, 2019 via email

@forki
Copy link
Member

forki commented Nov 23, 2019

I personally also think netstandard2 should be preferred over netcoreapp 1.

@kerams
Copy link
Contributor Author

kerams commented Nov 23, 2019

I think 1.6 and 2.0 is a different story. They are probably compatible. But
is this really the problem here?

It's important if the right target from the Nuget package's metadata is to be systematically chosen by finding the one which implements the highest .NET Standard version. The process could fall apart if there are breaking changes. Unless you just want to hard-code that netstandard2.0 takes precedence over netcoreapp1.1 when the project's target framework is > netcoreapp2.0?

@matthid
Copy link
Member

matthid commented Nov 23, 2019

I personally also think netstandard2 should be preferred over netcoreapp 1.

Last time I checked the process was specified as I mentioned above. This is not about personal preference ;) I'm happy to be corrected though.
Also this is not about netstandard1.6 and 2.0. The netcoreapp versioning is not related to the netstandard version. Any logic you might imagine is doomed to fail in the future.

@forki
Copy link
Member

forki commented Nov 23, 2019

Specified? As in a real spec? Where?

@matthid
Copy link
Member

matthid commented Nov 23, 2019

You can check that nuget applies the same logic. Just add netcoreapp3 as project framework and netcoreapp1 and netstandard2 as package framework here: https://nugettoolsdev.azurewebsites.net/5.3.0/get-nearest-framework?project=netcoreapp3.0&package=netcoreapp1.1%0D%0Anetstandard2.0

If you want different behavior the fix is to ask the package authors to add a netcoreapp3 build to the package or remove the netcoreapp1 one

@forki
Copy link
Member

forki commented Nov 23, 2019 via email

@matthid
Copy link
Member

matthid commented Nov 23, 2019

when in doubt I consult https://docs.microsoft.com/en-us/nuget/reference/target-frameworks or the nuget source directly. Any deviation usually resulted in more pain in the past - with the exception of the compat table between frameworks (which is not as important as preferring same framework, which this issue asks to deviate from)

@matthid
Copy link
Member

matthid commented Nov 23, 2019

Or asked differently: What would the change actually gets us? The current behavior works and runs, doesn't it?

@forki
Copy link
Member

forki commented Nov 23, 2019 via email

@matthid
Copy link
Member

matthid commented Nov 23, 2019

Nuget source is not a spec. ;)

Ok, but they clearly link that part of the source in their docs.

To elaborate with a different - more extreme - example. Consider a package with net10 and netstandard20. And you build for net48 (https://nugettoolsdev.azurewebsites.net/5.3.0/get-nearest-framework?project=net48&package=net10%0D%0Anetstandard2.0). In this scenario you (NuGet and Paket) would still prefer net10 because it is the SAME framework and netstandard20 would be framework "switch".

This is just how NuGet (and Paket) always behaved and package authors need to account for that when packaging their stuff.
There is basically no way to know for the package manager that the netstandard20 build has more APIs or would be more modern or anything, what would be the criteria?

@kerams
Copy link
Contributor Author

kerams commented Nov 23, 2019

Feature request for overrides in the Nuget client NuGet/Home#7416
Having this feature in Paket, at least in the form of overrides, could be attractive for some Nuget users.

@matthid
Copy link
Member

matthid commented Nov 23, 2019

Even if I would agree with the OP and would like to change this - which I clearly do not. What would be the criteria to switch to netstandard instead of preferring the same framework? Date of release of the framework? Version of the netstandard it implements?

Maybe once that is clear I can give some examples where this would be a bad idea in practice, which I think can be already given in the OP example: I just need to find one API available in netcoreapp1.1 and not in netstandard2.0 and then build a package using that API. Now if your project depends on it there is a real difference in behavior. I think such things exist as netcoreapp usually has some APIs very early.

@matthid
Copy link
Member

matthid commented Nov 23, 2019

IMHO NuGet/Home#7416 is not a valid example. This is just not how the system is designed. The author should have made a major version increase switching to M.E.F. and removed System.Configuration and old frameworks. Shipping different frameworks in a single nuget package with different API surfaces and dependencies like this is doomed to create problems if you don't know how the system works ;)

In any case my stand on this: Let the NuGet team figure it out if this is really a problem (which given only 2 comments on over a year probably doesn't think it is). If they change anything we can discuss on how to follow.

@kerams kerams closed this as completed Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants