Skip to content

Fix Native AOT SDK version lookup#55410

Merged
baronfel merged 1 commit into
release/11.0.1xx-preview7from
baronfel-fix-sdk-version-lookup
Jul 22, 2026
Merged

Fix Native AOT SDK version lookup#55410
baronfel merged 1 commit into
release/11.0.1xx-preview7from
baronfel-fix-sdk-version-lookup

Conversation

@baronfel

@baronfel baronfel commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • move SdkPaths into CoreUtils so DotnetFiles can use it without reversing the existing project dependency
  • resolve the SDK .version file from SdkPaths.SdkDirectory, making Product.Version correct in both managed and Native AOT hosts
  • verify separated Native AOT layouts (like the muxer) report the version from the resolved SDK directory

Fixes dotnet/dotnet#7901

Testing

  • dotnet build src/Cli/Microsoft.DotNet.Cli.CoreUtils/Microsoft.DotNet.Cli.CoreUtils.csproj -c Debug
  • dotnet build test/dotnet-aot.Tests/dotnet-aot.Tests.csproj -c Debug
  • Native AOT dn --version against a separated SDK layout with a synthetic .version file

Resolve the SDK .version file through SdkPaths so Product.Version works when the Native AOT CLI is loaded by the muxer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9c278b1d-69fa-4a23-be2f-d35ae29622a1
Copilot AI review requested due to automatic review settings July 22, 2026 14:54
@baronfel
baronfel requested review from a team, lbussell and mthalman as code owners July 22, 2026 14:54
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@baronfel

baronfel commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Once merged we'll want to backport to SDK main as well so that future release versions pick this up.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes SDK version resolution in the Native AOT CLI host by ensuring the .version file is resolved from the resolved versioned SDK directory (SdkPaths.SdkDirectory) rather than from AppContext.BaseDirectory, which can point at the install root in separated Native AOT layouts.

Changes:

  • Update .version file discovery to use SdkPaths.SdkDirectory, making Product.Version / --version correct in both managed and Native AOT hosts.
  • Add InternalsVisibleTo for Microsoft.DotNet.Cli.CoreUtils so SdkPaths can be shared with dotnet, dotnet-aot, and dotnet-aot.Tests.
  • Extend the separated-layout AOT integration test to validate --version reads the synthetic .version value from the resolved SDK directory.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/dotnet-aot.Tests/AotIntegrationTests.cs Adds an end-to-end assertion that dn --version uses the .version file from the resolved separated SDK directory.
src/Cli/Microsoft.DotNet.Cli.CoreUtils/SdkPaths.cs Updates comments to reflect CoreUtils location and clarifies Native AOT resolution behavior.
src/Cli/Microsoft.DotNet.Cli.CoreUtils/Microsoft.DotNet.Cli.CoreUtils.csproj Grants friend access to internals for dotnet, dotnet-aot, and dotnet-aot.Tests.
src/Cli/Microsoft.DotNet.Cli.CoreUtils/DotnetFiles.cs Resolves .version from SdkPaths.SdkDirectory instead of AppContext.BaseDirectory.
.github/skills/add-dotnet-aot-command/SKILL.md Updates guidance to reference SdkPaths being in Microsoft.DotNet.Cli.CoreUtils.

@baronfel
baronfel enabled auto-merge (squash) July 22, 2026 15:25
@baronfel
baronfel merged commit 585c3ba into release/11.0.1xx-preview7 Jul 22, 2026
30 checks passed
@baronfel
baronfel deleted the baronfel-fix-sdk-version-lookup branch July 22, 2026 16:58
@baronfel

Copy link
Copy Markdown
Member Author

/backport to main

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to main (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants