Skip to content

[dotnet] Set a default PublishRuntimeIdentifier again. Fixes #24547 - #26013

Merged
rolfbjarne merged 3 commits into
net11.0from
dev/rolf/issue-24547-figure-out-a-solution-for-setting-publis-39075a
Jul 16, 2026
Merged

rolfbjarne merged 3 commits into
net11.0from
dev/rolf/issue-24547-figure-out-a-solution-for-setting-publis-39075a

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Now that dotnet/sdk#54291 has merged and is available in our bundled SDK, we can set a default PublishRuntimeIdentifier again.

Background

We previously had to stop setting PublishRuntimeIdentifier because the .NET SDK appends it to RuntimeIdentifiers. We use RuntimeIdentifiers to mean "build for all these RIDs" (not just "restore for these RIDs"), so the appended publish RID left both RuntimeIdentifier and RuntimeIdentifiers set at the same time, which our build rejects with a validation error.

Change

Validated with a clean build; the new test passes for iOS and tvOS.

Fixes #24547

πŸ€– Pull request created by Copilot

We had to stop setting `PublishRuntimeIdentifier` because the SDK appends it
to `RuntimeIdentifiers`, which confuses our build (we use `RuntimeIdentifiers`
to mean "build for all these RIDs", not just "restore all these RIDs"), and we
ended up with both `RuntimeIdentifier` and `RuntimeIdentifiers` set.

The SDK now has an escape hatch for this behavior
(`AppendPublishRuntimeIdentifierToRuntimeIdentifiers=false`), so re-enable
setting `PublishRuntimeIdentifier` for iOS/tvOS and opt out of appending it to
`RuntimeIdentifiers`.

Also add a regression test.

Ref: dotnet/sdk#54291
Fixes #24547

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rolfbjarne
rolfbjarne changed the base branch from main to net11.0 July 9, 2026 14:13
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

Re-enables a default PublishRuntimeIdentifier for iOS/tvOS publishes, leveraging a new .NET SDK escape hatch to prevent the publish RID from being appended into RuntimeIdentifiers (which this repo treats as β€œbuild for all these RIDs”, and which can otherwise trigger RuntimeIdentifier/RuntimeIdentifiers clash validation errors).

Changes:

  • Re-enable default PublishRuntimeIdentifier values (ios-arm64 / tvos-arm64) in the shared SDK props.
  • Set AppendPublishRuntimeIdentifierToRuntimeIdentifiers=false to avoid the SDK mutating RuntimeIdentifiers.
  • Add a unit test regression check that PublishRuntimeIdentifier is set but not appended to RuntimeIdentifiers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/dotnet/UnitTests/PostBuildTest.cs Adds regression coverage validating PublishRuntimeIdentifier defaults don’t leak into RuntimeIdentifiers.
dotnet/targets/Xamarin.Shared.Sdk.props Restores default publish RID behavior for iOS/tvOS and opts out of SDK RID-appending behavior.

Comment thread dotnet/targets/Xamarin.Shared.Sdk.props Outdated
Comment on lines +156 to +160
<PublishRuntimeIdentifier Condition="'$(_PlatformName)' == 'tvOS'">tvos-arm64</PublishRuntimeIdentifier>
-->
<!-- Disable the default PublishRuntimeIdentifier behavior: https://github.com/dotnet/sdk/pull/52566 -->
<UseDefaultPublishRuntimeIdentifier>false</UseDefaultPublishRuntimeIdentifier>
<!-- Don't append PublishRuntimeIdentifier to RuntimeIdentifiers: we use RuntimeIdentifiers to mean "build for all these RIDs", and appending the publish RID confuses our build: https://github.com/dotnet/sdk/pull/54291 / https://github.com/dotnet/macios/issues/24547 -->
<AppendPublishRuntimeIdentifierToRuntimeIdentifiers>false</AppendPublishRuntimeIdentifierToRuntimeIdentifiers>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 6c34ce6. The two escape hatches (UseDefaultPublishRuntimeIdentifier=false and AppendPublishRuntimeIdentifierToRuntimeIdentifiers=false) are now set in an unconditional property group, so they apply even when a RuntimeIdentifier/RuntimeIdentifiers is specified explicitly. Only our default PublishRuntimeIdentifier value stays guarded by _XamarinUsingDefaultRuntimeIdentifier. Added a regression test covering the explicit-RID case.

…pecify a RuntimeIdentifier.

The default PublishRuntimeIdentifier we set was overriding an explicit
RuntimeIdentifier during publish (the SDK sets RuntimeIdentifier =
PublishRuntimeIdentifier when publishing). This turned simulator builds
into device builds, which broke the NativeAOT simulator tests (they set
an explicit simulator RuntimeIdentifier + PublishAot/_IsPublishing).

Guard the default so it only applies when the user didn't specify a
RuntimeIdentifier. We can't check '$(RuntimeIdentifier)' == '' because
we've already computed a default RuntimeIdentifier by this point, so we
check the _XamarinUsingDefaultRuntimeIdentifier property instead.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…ntifier behavior.

The escape hatches UseDefaultPublishRuntimeIdentifier=false and
AppendPublishRuntimeIdentifierToRuntimeIdentifiers=false must be set
unconditionally, regardless of whether a RuntimeIdentifier or
RuntimeIdentifiers was specified.

A previous iteration gated these together with our default
PublishRuntimeIdentifier behind _XamarinUsingDefaultRuntimeIdentifier.
That meant builds that specified an explicit RuntimeIdentifier (or a
plural RuntimeIdentifiers) lost the escape hatches, so the SDK computed
a default PublishRuntimeIdentifier (the host portable RID) and appended
it to RuntimeIdentifiers. For MacCatalyst 'link all' this produced the
clash "Building for all the runtime identifiers
'maccatalyst-x64;osx-arm64' at the same time isn't possible".

Split into two property groups: the escape hatches are now unconditional,
while our default PublishRuntimeIdentifier (ios-arm64/tvos-arm64) stays
guarded by _XamarinUsingDefaultRuntimeIdentifier so it doesn't clobber an
explicit RuntimeIdentifier.

Also add a regression test asserting the escape hatches are set even when
a RuntimeIdentifier is specified.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne marked this pull request as ready for review July 16, 2026 07:23
@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 16, 2026 07:24
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

βœ… API diff for current PR / commit

NET (empty diffs)

βœ… API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 6c34ce664efaf968f28a5b8346bc69ab199b5cd1 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

πŸš€ [CI Build #6c34ce6] Test results πŸš€

Test results

βœ… All tests passed on VSTS: test results.

πŸŽ‰ All 256 tests passed πŸŽ‰

Tests counts

βœ… assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
βœ… cecil: All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
βœ… dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
βœ… framework: All 2 tests passed. Html Report (VSDrops) Download
βœ… fsharp: All 4 tests passed. Html Report (VSDrops) Download
βœ… generator: All 5 tests passed. [attempt 3] Html Report (VSDrops) Download
βœ… interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
βœ… introspection: All 7 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… linker (iOS): All 31 tests passed. Html Report (VSDrops) Download
βœ… linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
βœ… linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
βœ… linker (tvOS): All 31 tests passed. Html Report (VSDrops) Download
βœ… monotouch (iOS): All 23 tests passed. Html Report (VSDrops) Download
βœ… monotouch (MacCatalyst): All 23 tests passed. Html Report (VSDrops) Download
βœ… monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
βœ… monotouch (tvOS): All 23 tests passed. Html Report (VSDrops) Download
βœ… msbuild: All 2 tests passed. Html Report (VSDrops) Download
βœ… sharpie: All 1 tests passed. Html Report (VSDrops) Download
βœ… windows: All 3 tests passed. Html Report (VSDrops) Download
βœ… xcframework: All 4 tests passed. Html Report (VSDrops) Download
βœ… xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

βœ… Tests on macOS Sonoma (14): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… Tests on macOS Sequoia (15): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
βœ… Tests on macOS Tahoe (26): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download

Linux Build Verification

βœ… Linux build succeeded

Pipeline on Agent
Hash: 6c34ce664efaf968f28a5b8346bc69ab199b5cd1 [PR build]

@rolfbjarne
rolfbjarne merged commit ac70365 into net11.0 Jul 16, 2026
54 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/issue-24547-figure-out-a-solution-for-setting-publis-39075a branch July 16, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure out a solution for setting PublishRuntimeIdentifier

4 participants