Skip to content

Fix PublishDotnetAot target NETSDK1047 error in CI#54114

Merged
NikolaMilosavljevic merged 4 commits into
dotnet:mainfrom
NikolaMilosavljevic:publish.aot.fix
May 1, 2026
Merged

Fix PublishDotnetAot target NETSDK1047 error in CI#54114
NikolaMilosavljevic merged 4 commits into
dotnet:mainfrom
NikolaMilosavljevic:publish.aot.fix

Conversation

@NikolaMilosavljevic

@NikolaMilosavljevic NikolaMilosavljevic commented Apr 27, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the NETSDK1047 build error introduced in #54056 that was worked around by disabling the target in #54067.

Root Cause

In CI, Arcade's centralized NuGet restore runs via NuGet.targets without RuntimeIdentifier, so the project.assets.json lacks the RID-specific target. When Targets="Restore;Publish\" was called with RuntimeIdentifier=, it failed with:

error NETSDK1047: Assets file 'artifacts\obj\dotnet-aot\project.assets.json' doesn't have a target for 'net11.0/win-x64'

Fix

Split the single Targets="Restore;Publish\" call into two separate MSBuild invocations:

  1. Restore with RuntimeIdentifiers (plural) - adds the RID target to the assets file
  2. Publish with RuntimeIdentifier (singular) - uses the now-complete assets file

This follows the established pattern from test/xunit-runner/XUnitRunner.targets:64-75 which handles the same CI/Arcade restore conflict.

Changes

  • Re-enabled the original target condition (TargetRid == HostRid on supported platforms)
  • Separated Restore from Publish into distinct MSBuild calls
  • Used RuntimeIdentifiers (plural) for Restore vs RuntimeIdentifier (singular) for Publish
  • Added explanatory comment documenting the NETSDK1047 workaround

In CI, Arcade's centralized NuGet restore runs without RuntimeIdentifier,
so the assets file lacks the RID-specific target. This caused NETSDK1047:
'Assets file doesn't have a target for net11.0/win-x64'.

Fix by splitting Restore and Publish into separate MSBuild calls:
- Restore with RuntimeIdentifiers (plural) to add RID target to assets
- Publish with RuntimeIdentifier (singular) to use the complete assets

Also re-enables the target (was disabled in PR dotnet#54067 as a workaround).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 20:24

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 addresses CI failures (NETSDK1047) when building/publishing the dotnet-aot NativeAOT shared library as part of SDK layout generation, caused by Arcade’s centralized restore not producing RID-specific restore targets.

Changes:

  • Re-enable PublishDotnetAot on supported host-native builds (TargetRid == HostRid for win/linux/osx).
  • Split the previous combined Restore;Publish MSBuild invocation into two calls: Restore using RuntimeIdentifiers, then Publish using RuntimeIdentifier.
  • Add an explanatory comment documenting the CI/Arcade restore behavior that leads to NETSDK1047.

IntermediateOutputPath controls build output, but NuGet Restore uses
BaseIntermediateOutputPath for project.assets.json location. Without this,
Arcade's centralized restore writes to artifacts/obj/dotnet-aot/ while
our Publish looks in artifacts/obj/dotnet-aot-redist/, causing NETSDK1047.

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

Copy link
Copy Markdown
Member Author

@copilot are all failures in checks unrelated? Are they all being tracked in issues or PRs?

@NikolaMilosavljevic

Copy link
Copy Markdown
Member Author

Unrelated failures in checks - merging on red.

@NikolaMilosavljevic NikolaMilosavljevic merged commit ee2499a into dotnet:main May 1, 2026
16 of 24 checks passed
@marcpopMSFT

Copy link
Copy Markdown
Member

@NikolaMilosavljevic I don't think all of the failures were unrelated. We've had a lot of noise so the tendency is to assume that but there are some build failures in here too.

Also, next time if you do have unrelated failures, don't merge on red. Use /ba-g to make the build green.

NikolaMilosavljevic added a commit that referenced this pull request May 1, 2026
The Microsoft.Build.Runtime package version 17.14.28 ships MSBuild.dll
under contentFiles/any/net9.0/, not net10.0/. This caused build failures
when the PublishDotnetAot target was re-enabled in PR #54114.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marcpopMSFT pushed a commit to NikolaMilosavljevic/sdk that referenced this pull request May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants