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

Enable "portable" RID graph when targeting .NET 8 and higher #34279

Merged
merged 3 commits into from
Aug 4, 2023

Conversation

dsplaisted
Copy link
Member

Resolves #34033

Projects targeting .NET 8 and higher will by default use the smaller, "portable" RuntimeIdentifier graph. They can opt in to the old, full RID graph by setting UseRidGraph to true. Likewise, projects targeting .NET 7 and earlier can use the trimmed-down RID graph by setting UseRidGraph to false (there may not be any scenario where this is needed though).

Additional runtime identifiers can be added to the portable RuntimeIdentifier graph when building the .NET SDK by defining AdditionalRuntimeIdentifier items in the redist.csproj project. This is to support source-built versions of the .NET SDK to add their own Runtime Identifiers. Here is an example of the format for these items:

 <ItemGroup>
   <AdditionalRuntimeIdentifier Include="ubuntu.14-x64" Imports="linux-x64" />
   <AdditionalRuntimeIdentifier Include="rhel-x64" Imports="linux-x64;linux" />
 </ItemGroup>

@dsplaisted dsplaisted requested review from AntonLapounov and a team as code owners July 26, 2023 16:20
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Jul 26, 2023
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just a few little comments 🙂


public override bool Execute()
{
JToken json;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a "fast path" here for if AdditionalRuntimeIdentifiers is null? Then it should just be a copy, right?

foreach (var rid in AdditionalRuntimeIdentifiers)
{
var importedRids = rid.GetMetadata("Imports").Split(';');
runtimes.Add(rid.ItemSpec, new JObject(new JProperty("#import", new JArray(importedRids))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct and updates json["runtimes"] rather than making a copy...but can we have a regression test for that? Or perhaps just add json["runtimes"] = runtimes at the end?

@@ -48,6 +48,19 @@ Copyright (c) .NET Foundation. All rights reserved.
<_GenerateSingleFileBundlePropertyInputsCache>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(_GenerateSingleFileBundlePropertyInputsCache)))</_GenerateSingleFileBundlePropertyInputsCache>
</PropertyGroup>

<!-- For .NET 8 and higher, we will by default use a simplified "portable" RID graph -->
<PropertyGroup Condition="'$(UseRidGraph)' == ''">
<UseRidGraph Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0'))">false</UseRidGraph>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was tripped up on this once and almost said this is incorrect when it's correct. UseRidGraph to me sounds like it means use the new thing, especially since the new thing is the "portable" rid graph...can we add portable to this name and flip its true/falseness? Or add full and not flip it?

@tmds
Copy link
Member

tmds commented Jul 26, 2023

This is to support source-built versions of the .NET SDK to add their own Runtime Identifiers

Is something needed (in addition to this PR) to use this during source-build?

cc @MichaelSimons

@dsplaisted
Copy link
Member Author

This is to support source-built versions of the .NET SDK to add their own Runtime Identifiers

Is something needed (in addition to this PR) to use this during source-build?

cc @MichaelSimons

Yes, there will need to be logic during source-build to add an AdditionalRuntimeIdentifier item for the source-build specific RuntimeIdentifier.

@tmds
Copy link
Member

tmds commented Jul 27, 2023

Yes, there will need to be logic during source-build to add an AdditionalRuntimeIdentifier item for the source-build specific RuntimeIdentifier.

Will someone look into this? Should we create an issue to track it?

@richlander
Copy link
Member

I assume this will make RC1. Yes?

@dsplaisted
Copy link
Member Author

I assume this will make RC1. Yes?

Not necessarily, it somewhat depends on dotnet/runtime#89598

@richlander
Copy link
Member

We should really push to make RC1. This change is pretty significant so it gets more concerning after that. Thoughts @elinor-fung?

@ViktorHofer
Copy link
Member

ViktorHofer commented Jul 31, 2023

I assume NuGet will use the minified graph as well for .NET 8 targeting projects with this change? How will it be able to find RID specific assets, i.e. runtimes/win/lib/net8.0/a.dll? Asking for dotnet/runtime packages which use RID specific assets and for APICompat / PackageValidation which uses NuGet APIs that require the current RID graph:

_conventions = new ManagedCodeConventions(s_runtimeGraph);

@richlander
Copy link
Member

It can still find portable RIDs like linux, linux-musl, osx, and win. It won't be able to find alpine or debian.

@dsplaisted
Copy link
Member Author

With #34349, these test failures may now be fixed.

/azp run

@dsplaisted
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dsplaisted dsplaisted merged commit e626b7f into dotnet:main Aug 4, 2023
16 checks passed
@dsplaisted
Copy link
Member Author

I've merged this, so it should make it into RC1.

We have the following breaking change issue: dotnet/docs#36466

I think we should also have breaking change notices for the following:

  • The original runtime behavior change where looking up native assets
  • This SDK change where we use the portable RID graph by default

Do we have breaking change issues filed for these? Maybe we should have one issue that describes all of these related changes, and if not they should at least be linked somehow.

@richlander @baronfel

@tmds
Copy link
Member

tmds commented Aug 4, 2023

@dsplaisted is there an open issue for updating the graph to include the non-portable rid during source-build?

@richlander
Copy link
Member

If there isn't one, can you create one @tmds ?

@dsplaisted
Copy link
Member Author

dotnet/source-build#3578 is also related to these overall changes, so we could use that to track adding RIDs to the graph during source-build if we want.

@elinor-fung
Copy link
Member

This is the breaking change notice for the runtime behaviour change for looking up RID-specific assets: https://learn.microsoft.com/dotnet/core/compatibility/deployment/8.0/rid-asset-list

I opened dotnet/docs#36527 for this SDK change. @dsplaisted could you fill it in with more details?

@dsplaisted dsplaisted added the breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug label Aug 8, 2023
@ghost
Copy link

ghost commented Aug 8, 2023

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET Breaking Change Notification DL.

Tagging @dotnet/compat for awareness of the breaking change.

@dsplaisted
Copy link
Member Author

I've updated the breaking change issue with the details on how to revert to the old build behavior.

@mthalman
Copy link
Member

@dsplaisted - When you refer to redist.csproj as the location for where these AdditionalRuntimeIdentifier items are to be placed, where is that exactly? Is it this: https://github.com/dotnet/installer/blob/main/src/redist/redist.csproj?

@dsplaisted
Copy link
Member Author

@dsplaisted - When you refer to redist.csproj as the location for where these AdditionalRuntimeIdentifier items are to be placed, where is that exactly? Is it this: https://github.com/dotnet/installer/blob/main/src/redist/redist.csproj?

@mthalman It actually needs to go in the project in the SDK repo: https://github.com/dotnet/sdk/blob/main/src/Layout/redist/redist.csproj

I would put it in or near the PublishPortableRuntimeIdentifierGraph target in https://github.com/dotnet/sdk/blob/main/src/Layout/redist/targets/GenerateLayout.targets, which is imported by the redist project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug needs-breaking-change-doc-created untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use trimmed-down RID graph for .NET 8 and higher
8 participants