Skip to content

Fix PublishDotnetAot target NETSDK1047 error in CI#54114

Open
NikolaMilosavljevic wants to merge 3 commits intodotnet:mainfrom
NikolaMilosavljevic:publish.aot.fix
Open

Fix PublishDotnetAot target NETSDK1047 error in CI#54114
NikolaMilosavljevic wants to merge 3 commits intodotnet:mainfrom
NikolaMilosavljevic:publish.aot.fix

Conversation

@NikolaMilosavljevic
Copy link
Copy Markdown
Member

@NikolaMilosavljevic NikolaMilosavljevic commented Apr 27, 2026

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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>
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.

2 participants