Repository navigation
Fix dotnet format forwarding under NativeAOT - #55920
Conversation
|
Azure Pipelines: 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: baronfel <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
We'll need to backport this to the release branches. |
There was a problem hiding this comment.
Pull request overview
Fixes dotnet format forwarding under the NativeAOT host by resolving dotnet-format tool assets from the versioned SDK directory (via SdkPaths.SdkDirectory) instead of AppContext.BaseDirectory, which can point at the muxer/install root in AOT scenarios.
Changes:
- Update
FormatForwardingAppto build the forwarded DLL/deps/runtimeconfig paths fromSdkPaths.SdkDirectory. - Add a NativeAOT-focused regression test that sets the SDK root AppContext value and asserts the forwarded
dotnet formatinvocation uses that SDK directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Cli/dotnet/Commands/Format/FormatForwardingApp.cs | Switches forwarded dotnet-format asset path resolution to SdkPaths.SdkDirectory to work correctly under NativeAOT. |
| test/dotnet-aot.Tests/FormatForwardingAppTests.cs | Adds regression coverage ensuring forwarded args use the AppContext-provided SDK directory. |
| private readonly struct SdkDirectoryScope : IDisposable | ||
| { | ||
| private readonly object? _previousSdkRoot = AppContext.GetData(SdkPaths.DataName); | ||
|
|
||
| public SdkDirectoryScope(string sdkDirectory) | ||
| { | ||
| AppContext.SetData(SdkPaths.DataName, sdkDirectory); | ||
| SdkPaths.ClearSdkDirectoryCacheForTests(); |
There was a problem hiding this comment.
Moved the helper into a single shared test/dotnet-aot.Tests/SdkDirectoryScope.cs and removed both local copies in 00edfd1.
Co-authored-by: baronfel <[email protected]>
Head branch was pushed to by a user without write access
|
@copilot the implementation leads to mixed-slashes on paths on windows. evaluate and fix please. |
Co-authored-by: baronfel <[email protected]>
dotnet formatcould resolve its bundled tool path from the muxer/install root under NativeAOT, causing forwarding to fail becausedotnet-format.dlllives in the versioned SDK directory.dotnet-formatdll, deps, and runtimeconfig paths fromSdkPaths.SdkDirectory.AppContext.BaseDirectoryfor SDK-relativeDotnetToolsassets.dotnet-formatpaths use that SDK directory.