Skip to content

Fix NETSDK1242 build error on NativeAOT and the Mono smoke test#130292

Merged
kotlarmilos merged 2 commits into
dotnet:mainfrom
kotlarmilos:mobile/fix-netsdk1242-mono-mobile-build
Jul 8, 2026
Merged

Fix NETSDK1242 build error on NativeAOT and the Mono smoke test#130292
kotlarmilos merged 2 commits into
dotnet:mainfrom
kotlarmilos:mobile/fix-netsdk1242-mono-mobile-build

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented Jul 7, 2026

Copy link
Copy Markdown
Member

Description

The latest .NET 11 SDK started enforcing NETSDK1242, which fails the build when a project targets a mobile platform with the Mono runtime. The CoreCLR mobile legs already pass /p:UseMonoRuntime=false, so the check never fires for them, but the NativeAOT legs do not, so during restore the mobile target frameworks of the multi-targeted libs.tests projects default to Mono and fail the build.

The .NET 11 SDK 11.0.100-preview.6.26352.110 added check NETSDK1242, which
errors when a project targets a mobile platform (ios/tvos/maccatalyst/android)
with the Mono runtime. The CoreCLR mobile legs already pass /p:UseMonoRuntime=false
so the check never fires for them, but the NativeAOT legs do not, so the mobile
inner target frameworks of the multi-targeted libs.tests projects default to Mono
during restore and fail the build.

Force UseMonoRuntime off whenever UseNativeAOTRuntime is set, since NativeAOT is
CoreCLR-based and never uses Mono. Separately, set the SDK opt-out on the single
Mono iOS simulator smoke test, which intentionally builds the product with Mono
and therefore cannot turn UseMonoRuntime off.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 10:02
@kotlarmilos kotlarmilos changed the title Fix NETSDK1242 build breaks on NativeAOT and the Mono smoke test Fix NETSDK1242 build error on NativeAOT and the Mono smoke test Jul 7, 2026
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone Jul 7, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @akoeplinger, @matouskozak, @simonrozsival
See info in area-owners.md if you want to be subscribed.

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

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 adjusts repo-wide MSBuild defaults and one iOS simulator pipeline leg to avoid SDK error NETSDK1242 when restoring/building multi-targeted projects that include mobile TFMs.

Changes:

  • Default UseMonoRuntime to false when UseNativeAOTRuntime=true, to prevent mobile inner TFMs from implicitly selecting Mono during restore.
  • Opt the Mono iOS simulator smoke-test pipeline leg out of the SDK’s unsupported Mono mobile runtime check via /p:_DisableCheckForUnsupportedMonoMobileRuntime=true.
Show a summary per file
File Description
eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml Adds an SDK-check opt-out property to the Mono iOS simulator smoke-test build arguments.
Directory.Build.props Defaults UseMonoRuntime=false when UseNativeAOTRuntime=true to avoid NETSDK1242 during restore of multi-targeted projects.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread Directory.Build.props Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 10:08
@kotlarmilos

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new

@kotlarmilos

Copy link
Copy Markdown
Member Author

/ba-g Native AOT builds and Mono smoke tests succeeded

@kotlarmilos
kotlarmilos merged commit 24ed2b0 into dotnet:main Jul 8, 2026
219 of 239 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jul 10, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
)

## Description

The latest .NET 11 SDK started enforcing `NETSDK1242`, which fails the
build when a project targets a mobile platform with the Mono runtime.
The CoreCLR mobile legs already pass `/p:UseMonoRuntime=false`, so the
check never fires for them, but the NativeAOT legs do not, so during
restore the mobile target frameworks of the multi-targeted `libs.tests`
projects default to Mono and fail the build.

---------

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants