diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs
index b458e471c57230..ecf9244e10808f 100644
--- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs
@@ -349,5 +349,29 @@ public void TypeScriptDefinitionsCopiedToWwwrootOnBuild(Configuration config, bo
Assert.False(fileExists, $"dotnet.d.ts should not exist at {dotnetDtsWwwrootPath} after the build with WasmEmitTypeScriptDefinitions={shouldEmit}");
}
}
+
+ [Theory]
+ [InlineData("true", false)]
+ [InlineData("false", true)]
+ [InlineData("", false)] // Default case
+ public void UseMonoRuntimeParameter(string useMonoRuntimeArg, bool expectUseMonoRuntimeProperty)
+ {
+ Configuration config = Configuration.Debug;
+ string extraArgs = string.IsNullOrEmpty(useMonoRuntimeArg) ? "" : $"--UseMonoRuntime {useMonoRuntimeArg}";
+ ProjectInfo info = CreateWasmTemplateProject(Template.WasmBrowser, config, aot: false, "usemonoruntime", extraArgs: extraArgs);
+
+ string projectFile = File.ReadAllText(info.ProjectFilePath);
+
+ // Verify UseMonoRuntime presence in the project file
+ bool containsUseMonoRuntime = projectFile.Contains("false");
+ if (expectUseMonoRuntimeProperty)
+ {
+ Assert.True(containsUseMonoRuntime, $"Expected false to be present in the project file when --UseMonoRuntime {useMonoRuntimeArg}");
+ }
+ else
+ {
+ Assert.False(containsUseMonoRuntime, $"Expected false to not be present in the project file when --UseMonoRuntime {useMonoRuntimeArg}");
+ }
+ }
}
}
diff --git a/src/mono/wasm/templates/templates/browser/.template.config/template.json b/src/mono/wasm/templates/templates/browser/.template.config/template.json
index bf63166031178d..c55411b4a9ea1b 100644
--- a/src/mono/wasm/templates/templates/browser/.template.config/template.json
+++ b/src/mono/wasm/templates/templates/browser/.template.config/template.json
@@ -48,6 +48,13 @@
"defaultValue": "net11.0",
"replaces": "netX.0",
"displayName": "framework"
+ },
+ "UseMonoRuntime": {
+ "type": "parameter",
+ "datatype": "bool",
+ "defaultValue": "true",
+ "description": "Whether to use the Mono runtime for WebAssembly.",
+ "displayName": "Use Mono Runtime"
}
}
}
diff --git a/src/mono/wasm/templates/templates/browser/browser.0.csproj b/src/mono/wasm/templates/templates/browser/browser.0.csproj
index dcc64ab68df696..d7cc6a17bfe1dd 100644
--- a/src/mono/wasm/templates/templates/browser/browser.0.csproj
+++ b/src/mono/wasm/templates/templates/browser/browser.0.csproj
@@ -3,6 +3,9 @@
netX.0
true
true
+
+ false
+