Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Description

Adds a --UseMonoRuntime boolean parameter to the wasmbrowser template that controls whether <UseMonoRuntime>false</UseMonoRuntime> is included in the generated project file when the parameter is set to false. Default is true.

Template changes:

  • Added UseMonoRuntime symbol in template.json (boolean, default: true)
  • Added conditional property in browser.0.csproj using template engine directives with inverted logic

Usage:

# Default behavior - no property emitted (Mono runtime used by default)
dotnet new wasmbrowser -n MyApp

# Explicitly disable Mono runtime
dotnet new wasmbrowser -n MyApp --UseMonoRuntime false

The logic is inverted so that <UseMonoRuntime>false</UseMonoRuntime> is only emitted when the parameter is explicitly set to false. When true (default), no property is emitted since Mono runtime is the default behavior for WebAssembly browser apps.

Testing:

  • Added UseMonoRuntimeParameter test covering true/false/default cases
  • Validates presence/absence of property in generated csproj with inverted logic

Contributes to dotnet/sdk#51240

Original prompt

Update the wasmbrowser template to add a --usemonoruntime parameter (default: true). When this parameter is set to true, add false to the generated project file. Ensure the template help text and documentation are updated, and add or update template tests to cover both parameter settings.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 18, 2025 14:39
Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Copilot AI changed the title [WIP] Update wasmbrowser template to add usemonoruntime parameter Add --UseMonoRuntime parameter to wasmbrowser template (default: true) Dec 18, 2025
Copilot AI requested a review from maraf December 18, 2025 14:47
Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Copilot AI requested a review from maraf December 19, 2025 12:32
Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
@maraf maraf changed the title Add --UseMonoRuntime parameter to wasmbrowser template (default: true) [browser][coreclr] Add --UseMonoRuntime parameter to wasmbrowser template (default: true) Dec 19, 2025
Copilot AI changed the title [browser][coreclr] Add --UseMonoRuntime parameter to wasmbrowser template (default: true) Add --UseMonoRuntime parameter to wasmbrowser template (default: true) Dec 19, 2025
Copilot AI requested a review from maraf December 19, 2025 14:09
@maraf maraf added arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm labels Dec 19, 2025
@maraf maraf added this to the 11.0.0 milestone Dec 19, 2025
@dotnet-policy-service
Copy link
Contributor

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

@maraf maraf changed the title Add --UseMonoRuntime parameter to wasmbrowser template (default: true) [browser][coreclr] Add --UseMonoRuntime parameter to wasmbrowser template (default: true) Dec 19, 2025
@maraf maraf marked this pull request as ready for review December 19, 2025 14:12
Copilot AI review requested due to automatic review settings December 19, 2025 14:12
Copy link
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 adds a new --UseMonoRuntime boolean parameter to the wasmbrowser dotnet template that controls whether the generated project explicitly opts out of the Mono runtime. The parameter defaults to true, and when set to false, the template emits <UseMonoRuntime>false</UseMonoRuntime> in the generated project file to enable CoreCLR for WebAssembly scenarios.

Key Changes:

  • Added UseMonoRuntime template parameter with boolean type and true default value
  • Implemented inverted conditional logic in project template to emit property only when parameter is false
  • Added comprehensive test coverage for all parameter scenarios (true, false, and default)

Reviewed changes

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

File Description
src/mono/wasm/templates/templates/browser/.template.config/template.json Adds the UseMonoRuntime boolean parameter definition with default value true and appropriate description
src/mono/wasm/templates/templates/browser/browser.0.csproj Adds conditional template directive to emit <UseMonoRuntime>false</UseMonoRuntime> only when parameter is set to false
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs Adds test method UseMonoRuntimeParameter to verify correct behavior for all parameter values (true, false, default)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@maraf maraf enabled auto-merge (squash) December 19, 2025 16:20
@maraf maraf merged commit f247d68 into main Dec 19, 2025
25 of 27 checks passed
@jkotas jkotas deleted the copilot/update-wasmbrowser-template branch December 22, 2025 05:36
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 os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants