-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WIP NO MERGE]: Add support for RuntimeFrameworkName to set the platform package for .NET Core 2.1 projects #2394
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
Conversation
This property can be set to control the .NET Core shared framework name. This is normally set to Microsoft.NETCore.App, the default .NET Core shared runtime.
…or when an unrecognized version is used
@@ -127,7 +127,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<When Condition="'$(RuntimeFrameworkName)' == 'Microsoft.AspNetCore.All'"> | |||
|
|||
<PropertyGroup> | |||
<DefaultPatchVersionForAspNetCoreAll2_1 Condition="'$(DefaultPatchVersionForAspNetCoreAll2_1)' == ''">2.1.1</DefaultPatchVersionForAspNetCoreAll2_1> | |||
<DefaultPatchVersionForAspNetCoreAll2_1 Condition="'$(DefaultPatchVersionForAspNetCoreAll2_1)' == ''">2.1.3</DefaultPatchVersionForAspNetCoreAll2_1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to be 2.1.1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natemcmaster is this in anticipation for aspnet/Universe#1256?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bingo. We want to add a dependency from AspNetCore.App -> NETCore.App in 2.1.3. This implementation and aspnet/Universe#1256 go hand in hand. This is one of the tradeoffs we'll try to balance with @DamianEdwards. Doing so would mean users with the explicit PackageReference to AspNetCore.App would get downgrade warnings about NETCore.App. I think we will be okay with that since we want to help users move to the RuntimeFrameworkName approach, but we need to discuss.
|
||
<Otherwise> | ||
<PropertyGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' "> | ||
<_UnrecognizedRuntimeFrameworkName>true</_UnrecognizedRuntimeFrameworkName> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does this mean there's no way for anyone to compose or use a different shared framework other than the ones we ship? I was under the impression that we want to support composable and custom shared frameworks at some point, maybe only for 3.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of locking this down until such a feature exists. It will be far easier to diagnose typos than generating a bogus packagereference with no version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was more about users unintentionally attempting to use something as a shared framework package which isn't. Composable and custom frameworks is a 3.0 which I don't think we need to address in the 2.1 SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good, I wasn't sure where that feature landed in terms of releases. Good to know it's only 3.0.
============================================================ | ||
--> | ||
<Target Name="_DefaultMicrosoftNETPlatformLibrary"> | ||
|
||
<PropertyGroup Condition="'$(MicrosoftNETPlatformLibrary)' == ''"> | ||
<MicrosoftNETPlatformLibrary Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">Microsoft.NETCore.App</MicrosoftNETPlatformLibrary> | ||
<MicrosoftNETPlatformLibrary>$(RuntimeFrameworkName)</MicrosoftNETPlatformLibrary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go with this change, I would wish this property didn't exist and there would only be RuntimeFrameworkName But that would be technically breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I hope we can drop it in 3.0. I think we have to keep it for 2.1 because the source-build guys (cc @tmds) will need to toggle this separately from RuntimeFrameworkName to workaround dotnet/source-build#375
provided by Microsoft.NETCoreSdk.BundledVersions.props --> | ||
<DefaultAspNetCoreAllPatchVersion Condition="'$(DefaultAspNetCoreAllPatchVersion)' == '' AND '$(_TargetFrameworkVersionWithoutV)' == '$(BundledAspNetCoreAllTargetFrameworkVersion)'">$(BundledAspNetCoreAllPackageVersion)</DefaultAspNetCoreAllPatchVersion> | ||
<!-- If not covered by the previous cases use the target framework version for the default patch version --> | ||
<DefaultAspNetCoreAllPatchVersion Condition="'$(DefaultAspNetCoreAllPatchVersion)' == ''">$(_TargetFrameworkVersionWithoutV)</DefaultAspNetCoreAllPatchVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to ever use TFM version as AspNetCoreAllVersion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same applies to other lines for Latest instead of Default and AspNetCoreApp, but I won't comment everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will in 2.2 (assuming we don't botch that metapackage, too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK since it's the ultimate fallback.
|
||
<Otherwise> | ||
<PropertyGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' "> | ||
<_UnrecognizedRuntimeFrameworkName>true</_UnrecognizedRuntimeFrameworkName> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of locking this down until such a feature exists. It will be far easier to diagnose typos than generating a bogus packagereference with no version.
Hardcoded list of known implicit packges that are added to project from default SDK targets implicitly. | ||
Should be re-visited when multiple TFM support is added to Dependencies logic. | ||
--> | ||
<DefaultImplicitPackages>$(RuntimeFrameworkName);NETStandard.Library</DefaultImplicitPackages> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe moving this out of .Common.targets to here will remove it from outer builds, which strictly speaking is a breaking change. I wouldn't normally be worried about something that is likely so obscure, but this is targeting a patch right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, we should move it back then. Would there be any harm in hard coding this list to this?
<DefaultImplicitPackages>Microsoft.AspNetCore.All;Microsoft.AspNetCore.App;Microsoft.NETCore.App;NETStandard.Library</DefaultImplicitPackages>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I have no idea what this actually does. 🙃
Looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's the design time targets for the dependency node that consume this. Studying the code. If it's what I think the hard-coding above should be fine, but I'm still not 100% sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to treat anything in this list as implicit but not look at IsImplicitlyDefined metadata. cc @abpiskunov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've moved this back to Microsoft.NET.Sdk.Common.targets with the aspnet list.
Btw, which branch should this PR change to? I don't see release/2.1.401 in this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, until now there was no dotnet/sdk changes for 2.1.401 (only dotnet/cli). it. Let's just leave it targeted at 2.1.4xx and if we decide to merge for 401, we can create the branch then.
… and add aspnet packages to the list
|
||
<!-- For libraries targeting .NET Core 2.0 or higher, don't include a dependency on Microsoft.NETCore.App in the package produced by pack. | ||
Packing an app (for example a .NET CLI tool) should include the Microsoft.NETCore.App package dependency. --> | ||
<PackageReference Update="Microsoft.NETCore.App" | ||
Condition="('$(OutputType)' != 'Exe') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '2.0')" | ||
PrivateAssets="All" | ||
Publish="true" /> | ||
Publish="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Publish=true is redundant now, right?
It feels like this should also be a conditional entry on the PackageReference. I'm having trouble following the rationale for Update in this case, but not for RuntimeFrameworkName != Microsoft.NETCore.App.
I suppose there could be a behavior change if user has explicit package ref and DisableImplict != true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this was that PrivateAssets="All" on NETCore.App only if OutputType == library, but for AspNetCore.App, PrivateAssets is always All (when using the implicit package version.)
I think the resolution to #2364 is to actually tweak this line so PrivateAsset="All" is always true unless PackageType== DotNetCliTool, but that's a separate change to make...didn't want to muddy the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, glad that's going in to 2.2.
Also, yes, the Publish="true" is redundant. I can remove that line.
@@ -25,7 +25,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
Hardcoded list of known implicit packges that are added to project from default SDK targets implicitly. | |||
Should be re-visited when multiple TFM support is added to Dependencies logic. | |||
--> | |||
<DefaultImplicitPackages>Microsoft.NETCore.App;NETStandard.Library</DefaultImplicitPackages> | |||
<DefaultImplicitPackages>Microsoft.AspNetCore.All;Microsoft.AspNetCore.App;Microsoft.NETCore.App;NETStandard.Library</DefaultImplicitPackages> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abpiskunov @davkean I'm trying to understand the consequences of changing this.
This gets passed here:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets
Line 269 in d6ad245
DefaultImplicitPackages="$(DefaultImplicitPackages)" |
And turned into a HashSet here:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs
Line 78 in f5db1af
ImplicitPackageReferences = GetImplicitPackageReferences(DefaultImplicitPackages); |
And marks things as ImplicitlyDefined based on HashSet alone here:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs
Line 171 in f5db1af
dependency.IsImplicitlyDefined = ImplicitPackageReferences.Contains(dependency.Name); |
What does dependency.IsImplicitlyDefined control in the Dependencies node? Does it impact anything else in the IDE?
It looks like this will mark explicit user package references to these packages as implicit, which feels wrong. Is that right?
At this point, my concerns are down to this (irrespective of which release this lands in):
|
IsImplicitlyDefined causes it to get a different icon and you can cannot remove or attempt to remove the item. |
I think the (existing) code is wrong then. It should be based on IsImplicitlyDefined metadata on the package reference. NuGet uses that AFAIK in package manager. I'm going to play around with this and file a bug if I'm right. |
I don't have context on above, but it respects it for all reference items: https://github.com/dotnet/project-system/search?q=IsImplicitlyDefined&unscoped_q=IsImplicitlyDefined. |
I'm also not sure what this does. I know the IsImplicitlyDefined item metadata already works in VS, regardless of the value of DefaultImplicitPackages, so maybe let's just not touch the thing we don't understand, eh?
Yes, I think this is a really thing to make sure we are clear on. The only reason we didn't metapackage chain in the first place was that we assumed there would always be two PackageReference items and that they would be kept in alignment through the implicit package version. But since many users are not actually using the implicit package version, they can put themselves into a place where their app will pull a standalone version of NETCore.App which is lower than what AspNetCore.App was compiled for. Although I hope this is rare, it can lead to runtime errors because of assembly version mismatch. I think the solution - one we should have done sooner - is to make sure Microsoft.AspNetCore.App declares in the package metadata its minimum NETCore.App version. The tricky bit here is timing. If we decide to hold off on this until 2.1.500, then we can't do sharedfx package chaining. Adding package chaining without this SDK feature would mean users cannot actually reference the AspNetCore.App 2.1.3 package without disabling some package downgrade warnings...(unless we take a totally different SDK change that looks at AspNetCore.App package version and modifies the implicit package version of Microsoft.NETCore.App to match it.) |
Microsoft.NETCore.App assembly versions change between patches? cc @steveharter |
…efaultImplicitPackages since we don't really know what it's used for
I don't think they do, but I don't want to rely on that always being true. Point is, running on a version of NETCore.App lower than what AspNetCore.App expects is never a good idea, and I believe our packages should codify this. |
Re DefaultImplicitPackages: Here's what I see in VS:
I think (2) is actually preferable so maybe the revert was premature, but it is beyond bizarre that the behavior is controlled by a hard-coded list of packages and not driven by metadata on the package ref. |
Agree about version mismatch between dependent shared frameworks, I was mostly just curious if the assembly versions actually change. |
What happens when IsImplicitlyDefined=’false’ or emtpy AND package name is in DefaultImplicitPackages?
|
It behaves the same in Dependencies node as (2) above. Only under SDK, not NuGet node, and you can't delete it. But it can now be uninstalled or updated in the NuGet UI. This is just weird. |
@abpiskunov Probably has context on how this stuff is supposed to work. |
One more thing to think about, and maybe we should address this in this PR. In this PRs current design, we would need to change dotnet/aspnetcore#3307 at the same time. For users with an explicit PackageReference who attempt to update to AspNetCore.App 2.1.3, they would see this:
I think we should also add a check that runs on CollectPackageReferences which looks for Microsoft.AspNetCore.App and Microsoft.AspNetCore.All as PackageReferences and can issue a warning or error like this:
Thoughts @dsplaisted @nguerrera @DamianEdwards ? |
I think that warning would make sense. We may not be able to get it localized if we do ship in patch. |
…All and add automated tests for the new warnings and errors
I've update the PR to issue a warning when there are explicit PackageReferences to AspNetCore.App/All. I've also begun adding automated tests to verify the behavior we want. To make sure this works as expected, I'm using in tests a build of our metapackage which would align with the results of this change: aspnet/Universe#1261 |
Agree on dropping the code snippet. We should just make sure the aka.ms link points to good docs on the subject. |
<value><![CDATA[NETSDK1071: A PackageReference for '{0}' was included in your project. This will cause issues when upgrading to 2.1.3 and higher. | ||
To upgrade, remove this PackageReference and add the RuntimeFrameworkName property to {1}. | ||
|
||
<value><![CDATA[NETSDK1071: A PackageReference for '{0}' was included in your project. This will cause issues when upgrading to 2.1.3 and higher. To upgrade, remove this PackageReference and add the RuntimeFrameworkName property to {1}. For more information, see {2}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop the CDATA now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Removed that along with the code snippet.
…T Core 2.1 and up
If we add this warning, we will need to update the https://aka.ms/sdkimplicitrefs link, or create a new one. The current content there doesn't directly apply to ASP.NET. |
Windows test failures don't appear to be related to my changes. They are complaining that the agent doesn't have .NET Framework 4.7.2 ref assemblies.
I don't understand what would have caused the Ubuntu test failures. Are these known issues in 2.1.4xx?
|
Agreed. Opened dotnet/docs#6482 |
The .NET 4.7.2 reference assembly failures should be fixed by #2401. You can also try re-running those legs, it seems the agents aren't consistent on what is installed. |
oops, misclicked on close |
Per conversation in person, we are no longer pursuing this fix in 2.1.4xx. |
Part of dotnet/aspnetcore#3307
Changes:
Marking as "NO MERGE" because there is still ongoing discussion about when this should happen (if at all). I've opened this PR so we can take a look at the actual impact on the SDK when implementing this. We're meeting later this afternoon to take a closer look.
TODO: add automated tests to verify this works on aspnet core packages
cc @DamianEdwards @dsplaisted @nguerrera @Petermarcu @tmds @vijayrkn