Repository navigation
Make bundled tools from dotnet/aspnetcore native AOT - #6720
Conversation
Port the effective changes from dotnet/aspnetcore#66663 into the VMR. Co-authored-by: Copilot <[email protected]>
Select the RID-specific dotnet-user-secrets package for SDK layout and teach the bundled tool resolver to honor DotnetToolSettings.xml executable runners. Co-authored-by: Copilot <[email protected]>
baronfel
left a comment
There was a problem hiding this comment.
Some thoughts on how we should do this better
Move bundled tool package download selection into a restore target and use SelectRuntimeIdentifierSpecificItems to choose the dotnet-user-secrets RID package. Co-authored-by: Copilot <[email protected]>
Keep dotnet-user-secrets RID-specific package selection separate from the other bundled tools so dev-certs and user-jwts continue to lay out under any. Co-authored-by: Copilot <[email protected]>
Use BundledDotnetTool metadata to opt tools into RID-specific package selection, so future ASP.NET Core bundled tools can move to Native AOT without adding package-specific layout logic. Co-authored-by: Copilot <[email protected]>
Enable Native AOT publishing for dotnet-dev-certs, move shared bundled tool AOT defaults into the tools build, and mark dev-certs as a RID-specific bundled SDK tool package. Co-authored-by: Copilot <[email protected]>
Enable Native AOT publishing for dotnet-user-jwts, use source-generated JSON metadata for its serialization paths, and mark it as a RID-specific bundled SDK tool package. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates the ASP.NET Core CLI tools that are bundled into the .NET SDK (dotnet-user-secrets, dotnet-user-jwts, dotnet-dev-certs) to be Native AOT compatible, primarily by switching tool JSON usage to source-generated serializers and by updating the SDK layout logic to prefer RID-specific tool packages. It also adds new smoke tests that publish the tools as Native AOT and validate a few end-to-end scenarios.
Changes:
- Update SDK tool layout to select RID-specific AspNetCore tool packages when available and add the selected packages as
PackageDownloaditems. - Make the three tools Native AOT-friendly (source-generated
System.Text.Jsoncontexts,PublishAot=true, and a single-fileAssembly.Locationfallback fix). - Add new Native AOT publish + smoke tests that run the published executables.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/sdk/test/dotnet.Tests/CommandFactoryTests/GivenADotnetToolsCommandResolver.cs | Adds a unit test covering executable-based tools via DotnetToolSettings.xml. |
| src/sdk/src/Layout/redist/targets/BundledDotnetTools.targets | Selects RID-specific tool packages and wires them into PackageDownload + layout copy. |
| src/sdk/src/Cli/dotnet/CommandFactory/CommandResolution/DotnetToolsCommandResolver.cs | Adds support for resolving executable tools via DotnetToolSettings.xml. |
| src/aspnetcore/src/Tools/Tools.slnf | Includes the new Native AOT test project in the tool solution filter. |
| src/aspnetcore/src/Tools/Shared/TestHelpers/NativeAotToolRunner.cs | New helper to execute published Native AOT tool binaries with timeout + isolated profile env. |
| src/aspnetcore/src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs | Adjusts SecretManager.targets discovery for single-file/AOT scenarios. |
| src/aspnetcore/src/Tools/NativeAot/test/NativeAotToolScenarioTests.cs | Adds end-to-end smoke scenarios for user-secrets/user-jwts/dev-certs. |
| src/aspnetcore/src/Tools/NativeAot/test/NativeAotToolEntryPointTests.cs | Adds “entry point runs/--help works” coverage for the published tools. |
| src/aspnetcore/src/Tools/NativeAot/test/Microsoft.AspNetCore.Tools.NativeAot.Tests.csproj | New test project that publishes tools as Native AOT before running tests; ships outputs to Helix. |
| src/aspnetcore/src/Tools/dotnet-user-secrets/src/Internal/SecretsStore.cs | Switches secrets JSON serialization to source-generated context (AOT-friendly). |
| src/aspnetcore/src/Tools/dotnet-user-secrets/src/Internal/ListCommand.cs | Uses the new SecretsStore.Serialize helper for JSON output. |
| src/aspnetcore/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj | Enables PublishAot for the tool project. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Helpers/SigningKeysHandler.cs | Switches JSON nodes/serialization to source-generated context APIs. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Helpers/JwtStore.cs | Switches JWT store JSON read/write to source-generated context. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Helpers/JwtSerializerOptions.cs | Adds a JsonSerializerContext for source-generated serialization. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Helpers/JwtAuthenticationSchemeSettings.cs | Uses source-generated context for appsettings JSON manipulation. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Helpers/DevJwtCliHelpers.cs | Uses source-generated context for JSON output. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/dotnet-user-jwts.csproj | Enables PublishAot for the tool project. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Commands/ListCommand.cs | Uses source-generated context for JSON output. |
| src/aspnetcore/src/Tools/dotnet-user-jwts/src/Commands/CreateCommand.cs | Uses source-generated context for JSON output. |
| src/aspnetcore/src/Tools/dotnet-dev-certs/src/Program.cs | Switches cert report JSON output to source-generated context; adjusts DTO for serialization. |
| src/aspnetcore/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj | Enables PublishAot for the tool project. |
| src/aspnetcore/src/Tools/Directory.Build.targets | Adds AOT-specific tool build settings and disables AOT for source-only builds. |
| src/aspnetcore/src/Tools/Directory.Build.props | Defines the RID set used for bundled tool publishing. |
| src/aspnetcore/AspNetCore.slnx | Adds the new Native AOT test project to the main solution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BrennanConroy
left a comment
There was a problem hiding this comment.
Generally good, some other folks should look closer at the msbuild and tool invocation change.
Co-authored-by: Copilot <[email protected]>
Guard Native AOT tool publishing in source-only builds before restore evaluation and restore RID-specific bundled tool packages using the current ASP.NET Core package version. Co-authored-by: Copilot <[email protected]>
Set RuntimeIdentifiers next to PublishAot so source-only builds avoid AOT restore inference and regular builds expose the RID list before SDK runtime identifier inference. Co-authored-by: Copilot <[email protected]>
Move PublishAot and RuntimeIdentifiers into a dedicated source-build-gated property group for each bundled tool project. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
baronfel
left a comment
There was a problem hiding this comment.
The tool resolver changes are good on the SDK side of things, thanks for plumbing this through!
| <UsingTask TaskName="Microsoft.NET.Build.Tasks.SelectRuntimeIdentifierSpecificItems" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" /> | ||
|
|
||
| <PropertyGroup> | ||
| <AspNetCoreRidSpecificToolPackageRids>linux-x64;linux-arm;linux-arm64;linux-musl-x64;linux-musl-arm;linux-musl-arm64;win-x64;win-x86;win-arm64;osx-x64;osx-arm64</AspNetCoreRidSpecificToolPackageRids> |
There was a problem hiding this comment.
When we are building .NET for community platforms like linux-riscv64 or freebsd-arm64 (currently, there are nine of them), it should account for it. With the same token, those platforms tools aren't required in MSFT SDK.
IOW, we are missing "current target RID" in the list.
🚨 NativeAOT linker failure on musl/cross-build legs in VMR rolling buildsSince this PR merged, all internal Affected legsLinux_Alpine_arm64, Linux_Alpine_x64, Linux_arm64, Linux_arm, Linux_Pgo_x64, Linux_Pgo_arm64 — all cross-compilation or musl targets. BisectLast green: build 2981555 (sha CauseThe NativeAOT ILCompiler passes Possible fixes
|
This is our go-to way for official builds. You can just copy this target and it should work https://github.com/dotnet/runtime/blob/2dce83ad91efd1efbf974eb636a18f9b0fcdcb17/eng/toolAot.targets#L28C1-L48C12 (uses a script from arcade's eng/common so it's available everywhere) PS - |
Additional details on the
|
This updates the tools bundled into the SDK from dotnet/aspnetcore to be published native AOT. Adds coarse-grained smoke tests that exercise the main functionality of the tools after they've been published.
Tools effected:
dotnet user-secretsdotnet user-jwtsdotnet dev-certsThe published size of each tool locally on
win-x64is: