Consuming CoreFx packages on desktop
We currently run into a couple issues consuming CoreFx packages on desktop:
- ResolveAssemblyReferences (RAR) doesn't unify facade revisions in the same way the desktop loader does. This results in binding redirects incorrectly being emitted rather than ignoring the difference and unifying to the inbox version. For example System.Runtime 4.0.21.0 will be unified to the 4.0.0.0 assembly by the desktop loader, but RAR will see multiple revisions (eg: 4.0.0.0 and 4.0.21.0) and emit a binding redirect.
- ImplicitlyExpandDesigntimeFacades is adding facades when we want out-of-band facades from the packages to be preferred. The result is that the compiler will see two copies of the same assembly. This happens because it runs late, after RAR so there is no point to consider the different versions of inbox and out-of-band facades and choose the higher-versioned out of band facades.
To solve issue 1 we could try to change RAR to honor the desktop unification policy but that is a very risky change and could only be done in the latest version of VS. Instead I'd like to change how we version assemblies which are inbox on desktop.
Today we apply uniform versioning policy to all assembly versions, that policy is tied to SemVer as well as the desktop unification rules.
- Bug-fix changes that don't impact surface area are revision changes (3rd part)
- API changes or moves from inbox to out of box are minor version changes (2nd part).
- Major version is primarily for branding or breaking changes (though we currently never intend to have breaking changes for all stable assemblies).
I suggest we relax the first constraint for assemblies that also ship inbox in desktop. In other words, if the assembly major.minor version is part of the desktop framework, never change revision. One of the main reasons we change the revision is to guarantee uniqueness of the assembly should someone decide to put it in the GAC. This isn't really an issue for the desktop assemblies since the OS places them in the GAC and they should be protected so that folks cannot overwrite them outside of an OS patch. Also, we'll never ship a substantial revision to these that needs to be delivered to desktop without changing the minor version since we'd need to break out of unification. This does complicate the package build a bit but its better to absorb that compexity in our own package build than push that complexity out to developers.
To solve issue 2 we need a fix for ImplicitlyExpandDesigntimeFacades. At a minimum we can disable this to unblock folks. A better fix is to update the inbox targets to only add facades that don't overlap with the output of RAR, similar to how the nuget targets only add framework references for those assemblies which don't overlap with the resolved dlls. If folks need that fix without an update to VS we can share the updated targets.
Cc @schellap
A -> B -> S.R 4.0.21 A -> C -> S.R 4.0.22 A -> S.R 4.0.21
Even if I target the same netstandard version those packages it will fail at runtime. The problem is the assembly version isn't the same across package versions in the same netstandard folder.
This will get fixed by this refactoring, coincidentally. This refactoring will only fix the problem for assemblies that happen to be inbox on desktop. For out-of-box assemblies we still need to follow the semantic versioning scheme in assembly versions to guard against folks installing the assemblies in the GAC.
The graph your pointing out actually looks a little concerning. Can you give me a concrete example you're seeing today so I can confirm that this fix will address it?
thr versioning can be as semantic as you want, but it can't vary from package to package for the same netstandard version.
All it takes is for an application to target a lower package version for the same netstandard then boom. It probably breaks lineups as well. I need to look at that
application to target a lower package version for the same netstandard then boom
That is a downgrade: any time an application downgrades a package you get BOOM if that package has a lower assembly version. NETStandard is unnecessary qualification. App > Json.NET 8.1, App > Foo > Json.NET 8.2; App wins; Foo tries to load Json.NET; ref-def mismatch; BOOM.
We don't expect the downgrade to exist in any package graph we ship. In other words referencing any single package should not have a downgrade in its full closure, both compile and runtime. If a downgrade is showing up that is a bug that we'll need fix it.
Somebody ran into this today:
https://jabbrlive.blob.core.windows.net/jabbr-uploads/clipboard_06c2.png
as a direct result of the contract version variance between different package versions.
Yep thats a downgrade.
Yep!
Yep thats a downgrade.
A nasty one, it ruined everything on my machine :smile:
But you do agree that in principle the folder should dictate the version of the reference assembly right?
For things in NETStandard.Library, perhaps (though this does go against the business need in some cases). For things above: no. Consider that as a pure IL library I might grow my surface area over time without taking any dependency on a new version of NETStandard. In that case I'll version my pure IL assembly but keep it in the same folder.
For things above: no. Consider that as a pure IL library I might grow my surface area over time without taking any dependency on a new version of NETStandard. In that case I'll version my pure IL assembly but keep it in the same folder.
Agreed. I only mean ref only things that version with the netstandard TFM itself.
@PinpointTownes did NuGet warn you about the downgrade? It should have. I still think we should fix this, but that's something to look out for.
Thinking about this issue some more and I think we can further relax application of semver to the assembly versions. For any assembly that is a pure facade on desktop it can also freeze its assembly version to API. Only for those assemblies which are supported on desktop and contain actual code do we need to rev the third portion of the version.
/cc @weshaggard
AFAICT, nope, no warning. That said, I didn't use NuGet to restore the packages but VS' DNX tooling, so maybe the behavior is a bit different.
I actually ran the NuGet Restore and I got no warning at all either. This is a pretty big deal on my end because now my development is at a complete standstill. I hope this can get fixed soon
DNX tooling
@PinpointTownes Multiple problems with that... DNX is missing the validation checks that NuGet has. Additionally DNX has a bundled copy of most of the packages so it's never safe to use newer packages than what DNX was built with. The downgrade didn't happen as a result of packages, it happened because DNX ignored what was in the packages. That's an issue we're solving with the DotNET CLI which is replacing DNX.
@chrisjmccrum it's unclear to me if you're talking about downgrade issues or the desktop behavior which this issue is tracking.
Let's keep this issue on topic. This issue is tracking better desktop support in the packages. If folks are hitting issues around NuGet downgrades with no warning let's get a separate issue opened.
I'd really like to use CLI but sadly, it's far from being stable (and that's an euphemism): it doesn't handle the space in my Windows session folder and crashes systematically when launching dotnet run ; it throws a bunch of AccessViolationExceptions and the latest installer doesn't install anything (it immediately completes saying everything was fine, but nothing is copied to the disk).
Oh and there's no CLI tooling for VS yet :smile:
I totally understand that you're fully focusing on CLI and that DNX will disappear soon but adding breaking changes that ruin the existing stuff without having a solid replacement is a bit harsh, IMHO.
@ericstj Is there any document that talks about the assembly versioning scheme with respect to netstandard? I agree that we shouldn't rathole on this issue about general downgrades but I think it's important to understand how assembly versions in reference assemblies and package versions correlate and how that affects desktop and everything else.
We follow semver in the assembly versions where we can. In desktop we are planning to relax that to only major.minor if the assembly is inbox. The version of the package is the maximum assembly version it contains. If that collides with a previously shipped package and there is a change over that package we will increment revision. Doc is tracked by https://github.com/dotnet/corefx/issues/5453
@pinpointtownes any change to any assembly is breaking in that sense. Dnx doesn't pick up the implementation assemblies. If you're using dnx, you cannot upgrade packages.
@ericstj What happens if I target System.Runtime 4.1.0 for netstandard1.5 and run on .NET Framework?