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.

Make .NET Framework fallback open-ended

See original GitHub issue

When a developer references a NuGet package that doesn’t provide any assets for the current .NET platform, the SDK will fallback to try .NET Framework assets, provided the current .NET platform supports at least .NET Standard 2.0.

The fallback works by telling the NuGet selection algorithm “pretend I’m .NET Framework 4.6.1 so select me assets for that”. We determined that to be unfortunate and would like to change that to .NET Framework 5.0.

The rationale being:

  • It will automatically work for all current and future 4.x releases
  • We don’t plan on shipping another side-by-side release of the .NET Framework
  • Given that this mapping is best effort and one way only, even if we do ship a 5.0.0, nothing bad would happen. Worst case, we have to bump the mapping to an even higher version.

Update

@nguerrera raised concerns regarding breaking people. So we generally want an algorithm that picks the “smallest” .NET Framework as that wouldn’t change the behavior from today or we add new versions of .NET Framework. So I propose instead of mapping it straight to 5.0 we do this:

AssetTargetFallback = net461;net462;net47;net471;net472;net48

/cc @weshaggard @ericstj @davidfowl @Petermarcu @dsplaisted @nguerrera

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:29 (29 by maintainers)

github_iconTop GitHub Comments

2reactions
terrajobstcommented, Aug 10, 2018

@joperezr

That’s a very good point and I’m glad you pointed this out. As @nguerrera said:

The whole episode of retroactively making things compatible with netstandard 1.5+, and thereby changing assets resolved with an sdk upgrade, still gives me nightmares…

👍 😱

@nguerrera

If we want assets for “lowest version of .NET Framework that succeeds” in general, then I think we need nuget changes, and that it would be expensive to implement, but I’m not 100% sure I have the AssetTargetFallback behavior exactly right in this analysis.

Couldn’t we just do this:

AssetTargetFallback = net461;net462;net47;net471;net472;net48

I understand that this is less ideal than implementing the actual logic, but given how often .NET Framework ships, this might be a good compromise. The “nice” thing about this is that adding new items to the right isn’t a breaking change as it would only make more scenarios work that previously would have resulted in no assets, so even if the SDK doesn’t ship exactly at the same time as the .NET Framework targeting pack, the worst that can happen is that customers complain that certain NuGet packages (i.e. the ones that target the latest version of the .NET Framework) aren’t consumable via the compatibility mode, which in general should be rare as packages under active development hopefully offer a .NET Standard asset anyway.

Thoughts?

1reaction
terrajobstcommented, Mar 25, 2019

Should the ordering go the other way? If an asset exists for both net48 and net461, should we actually prefer the net48 one?

@nguerrera already addressed the compat angle. But more importantly, the .NET Framework compat mode is best effort. If a package overs 4.6.1 and 4.8, presumably that’s because it uses more features in the 4.8 binary. The 4.6.1 binary has a higher chance of working in .NET Standard compliant implementations though, which is why it still makes sense to prefer them over the later assets.

As far as the perf riks goes: assuming the perf hit only slows down error cases, then I’m OK with that, unless the result is unbearable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking change: Fallback file endpoints - .NET
This breaking change partially addresses the issue by making fallback file endpoints only match GET and HEAD requests. Version introduced. ASP.
Read more >
Cannot select Target Framework 4.5 in Visual Studio 2015
NET 4.6.2 framework on my windows 10 development pc. Then i've openend my solution which contains projects that target .NET Framework 4.5 ...
Read more >
Professional .NET Framework 2.0
It provides a higher-level programming facility with which to write generalized code for diverse use cases. The .NET Framework libraries have in.
Read more >
Handling SPA Fallback Paths in a Generic ASP.NET Core ...
When building ASP.NET Core backends for SPA applications one thing that you have to worry about is how to handle client side routes...
Read more >
NET Core vs .NET Framework - What's the difference?
NET Framework while at the same time being an obviously upgraded and improved version of MVC. If you want to learn more, make...
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