Skip to content

[wasm] Don't import the Mono wasm props on the CoreCLR path - #131420

Open
lewing wants to merge 2 commits into
dotnet:mainfrom
lewing:lewing-wasm-coreclr-sdk-props
Open

[wasm] Don't import the Mono wasm props on the CoreCLR path#131420
lewing wants to merge 2 commits into
dotnet:mainfrom
lewing:lewing-wasm-coreclr-sdk-props

Conversation

@lewing

@lewing lewing commented Jul 27, 2026

Copy link
Copy Markdown
Member

Alternative to #131372, following @maraf's review feedback there: keep the CoreCLR wasm targets a standalone set instead of conditioning the shared Mono props.

Problem

Publishing a browser-wasm app with the experimental CoreCLR wasm SDK fails with:

error MSB4057: The target "_WasmBuildAppCore" does not exist in the project.
  (BrowserWasmApp.CoreCLR.targets(216))

Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets.in imported BrowserWasmApp.props unconditionally (and through it WasmApp.Common.props), then picked the targets file per flavor. So the CoreCLR path inherited Mono's WasmNestedPublishAppDependsOn=_WasmBuildAppCore, a target defined in WasmApp.Common.targets, which the CoreCLR path never imports.

Fix

Condition the BrowserWasmApp.props import on Mono, matching the existing per-flavor targets split:

<Import Project="...\BrowserWasmApp.props"           Condition="'$(UseMonoRuntime)' != 'false'" />
<Import Project="...\BrowserWasmApp.targets"         Condition="'$(UseMonoRuntime)' != 'false'" />
<Import Project="...\BrowserWasmApp.CoreCLR.targets" Condition="'$(UseMonoRuntime)' == 'false'" />

CoreCLR needs no props counterpart:

  • RuntimeIdentifier is set by WasmSdk/Sdk/Sdk.props and by our Microsoft.NET.Sdk.WebAssembly.Pack.props, both before this Sdk.targets runs.
  • TargetOS / TargetArchitecture are only consumed in-tree (eng/native.wasm.targets), where eng/OSArch.props already derives both from RuntimeIdentifier == 'browser-wasm'. That is why in-tree CoreCLR works today without ever importing BrowserWasmApp.props.

The Mono files are untouched.

Validation

Staged a replica of the packaged SDK layout (generated Sdk.targets from the template plus the Sdk-dir files) and ran msbuild against it:

Scenario Result
UseMonoRuntime=false RID=browser-wasm IsBrowserWasmProject=true TargetsBrowser=true, Mono depends-on lists empty
UseMonoRuntime=true unchanged: _WasmBuildAppCore in both lists, WasmAppRuntimeFlavor=Mono
UseMonoRuntime unset identical to the Mono case
Invoke WasmNestedPublishApp for CoreCLR, before the change reproduces the MSB4057 above
Same, after the change runs clean: ResolveRuntimePackAssets -> Publish -> _GatherWasmFilesToPublish -> CoreCLR targets

The last pair also confirms the WebAssembly SDK's prepend to WasmNestedPublishAppDependsOn (_GatherWasmFilesToPublish) still composes on the CoreCLR side, as does PrepareForWasmBuildApp from eng/testing/tests.browser.targets.

Not affected: in-tree builds of either flavor (already split by RuntimeFlavor), WASI (no packaged CoreCLR split, and its CoreCLR targets define no nested-publish target), and the Helix/WBT CoreCLR leg (imports BrowserWasmApp.CoreCLR.targets directly).

Note

This change was drafted with GitHub Copilot.

The workload pack's Sdk.targets imported BrowserWasmApp.props (and through it
WasmApp.Common.props) unconditionally, so the CoreCLR flavor picked up Mono's
WasmNestedPublishAppDependsOn=_WasmBuildAppCore even though WasmApp.Common.targets,
which defines that target, is never imported on the CoreCLR path. Publishing a
CoreCLR browser-wasm app therefore failed with:

  MSB4057: The target "_WasmBuildAppCore" does not exist in the project.

Add BrowserWasmApp.CoreCLR.props with just the flavor-neutral properties
(TargetOS/TargetArchitecture/RuntimeIdentifier) and import the props/targets pair
per flavor, mirroring what the in-tree WasmApp.InTree.props/targets already do.
The Mono files are untouched.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b49e36e8-8a37-48ef-b7e8-54ac6443ea19
Copilot AI review requested due to automatic review settings July 27, 2026 14:26
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@lewing

lewing commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@maraf this?

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 fixes the packaged Microsoft.NET.Runtime.WebAssembly.Sdk import chain for the experimental CoreCLR browser-wasm flavor by ensuring it imports a matched props+targets pair per runtime flavor, avoiding Mono-only property defaults leaking into the CoreCLR targets graph.

Changes:

  • Make the packaged SDK’s Sdk.targets template import BrowserWasmApp.props only for Mono (UseMonoRuntime != false), and import a new BrowserWasmApp.CoreCLR.props for CoreCLR (UseMonoRuntime == false).
  • Add BrowserWasmApp.CoreCLR.props containing only the minimal flavor-neutral properties needed by the CoreCLR path.
  • Include the new .props file in the SDK NuGet package layout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets.in Splits imports so Mono and CoreCLR each get a consistent props+targets pair.
src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj Packages the new CoreCLR props file into the SDK’s Sdk/ directory.
src/mono/browser/build/BrowserWasmApp.CoreCLR.props New CoreCLR-specific props file providing TargetOS, TargetArchitecture, and RuntimeIdentifier without Mono-only target list defaults.

@lewing lewing added the arch-wasm WebAssembly architecture label Jul 27, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@lewing
lewing requested a review from radekdoulik July 27, 2026 14:56

@maraf maraf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@maraf this?

Yes ❤️

Comment thread src/mono/browser/build/BrowserWasmApp.CoreCLR.props Outdated
Per review feedback, none of the three properties are needed:

- RuntimeIdentifier is set by the WebAssembly SDK (WasmSdk/Sdk/Sdk.props and
  Microsoft.NET.Sdk.WebAssembly.Pack.props), both before this Sdk.targets runs.
- TargetOS/TargetArchitecture are only consumed in-tree (eng/native.wasm.targets);
  eng/OSArch.props already derives both from RuntimeIdentifier == 'browser-wasm',
  which is why in-tree CoreCLR works today without importing BrowserWasmApp.props.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b49e36e8-8a37-48ef-b7e8-54ac6443ea19
Copilot AI review requested due to automatic review settings July 27, 2026 18:13
@lewing lewing changed the title [wasm] Give the CoreCLR wasm SDK its own props [wasm] Don't import the Mono wasm props on the CoreCLR path Jul 27, 2026
@lewing
lewing marked this pull request as ready for review July 27, 2026 18:15
@lewing
lewing requested a review from akoeplinger as a code owner July 27, 2026 18:15
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@lewing

lewing commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@maraf even better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants