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 b2ae216e23db6..346ea52ad7f7f 100644 --- a/src/mono/wasm/templates/templates/browser/.template.config/template.json +++ b/src/mono/wasm/templates/templates/browser/.template.config/template.json @@ -8,6 +8,7 @@ "identity": "WebAssembly.Browser.7.0", "description": "WebAssembly Browser App", "name": "WebAssembly Browser App", + "description": "A project template for creating a .NET app that runs on WebAssembly in a browser", "shortName": "wasmbrowser", "sourceName": "browser.0", "preferNameDirectory": true, diff --git a/src/mono/wasm/templates/templates/browser/main.js b/src/mono/wasm/templates/templates/browser/main.js index 32c1599749d1d..6d9bd43f7eb7b 100644 --- a/src/mono/wasm/templates/templates/browser/main.js +++ b/src/mono/wasm/templates/templates/browser/main.js @@ -3,15 +3,12 @@ import { dotnet } from './dotnet.js' -const is_browser = typeof window != "undefined"; -if (!is_browser) throw new Error(`Expected to be running in a browser`); - -const { setModuleImports, getAssemblyExports, getConfig, runMainAndExit } = await dotnet +const { setModuleImports, getAssemblyExports, getConfig } = await dotnet .withDiagnosticTracing(false) .withApplicationArgumentsFromQuery() .create(); -setModuleImports("main.js", { +setModuleImports('main.js', { window: { location: { href: () => globalThis.window.location.href @@ -24,5 +21,5 @@ const exports = await getAssemblyExports(config.mainAssemblyName); const text = exports.MyClass.Greeting(); console.log(text); -document.getElementById("out").innerHTML = `${text}`; -await runMainAndExit(config.mainAssemblyName, ["dotnet", "is", "great!"]); \ No newline at end of file +document.getElementById('out').innerHTML = text; +await dotnet.run(); \ No newline at end of file diff --git a/src/mono/wasm/templates/templates/console/.template.config/template.json b/src/mono/wasm/templates/templates/console/.template.config/template.json index 1410c600679e0..e59261e64e771 100644 --- a/src/mono/wasm/templates/templates/console/.template.config/template.json +++ b/src/mono/wasm/templates/templates/console/.template.config/template.json @@ -7,6 +7,7 @@ "identity": "WebAssembly.Console.7.0", "description": "WebAssembly Console App", "name": "WebAssembly Console App", + "description": "A project template for creating a .NET app that runs on WebAssembly on Node JS or V8", "shortName": "wasmconsole", "sourceName": "console.0", "preferNameDirectory": true, diff --git a/src/mono/wasm/templates/templates/console/main.mjs b/src/mono/wasm/templates/templates/console/main.mjs index 1072711c59c6d..6dd163a3741b3 100644 --- a/src/mono/wasm/templates/templates/console/main.mjs +++ b/src/mono/wasm/templates/templates/console/main.mjs @@ -3,14 +3,11 @@ import { dotnet } from './dotnet.js' -const is_node = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string'; -if (!is_node) throw new Error(`This file only supports nodejs`); - -const { setModuleImports, getAssemblyExports, getConfig, runMainAndExit } = await dotnet +const { setModuleImports, getAssemblyExports, getConfig } = await dotnet .withDiagnosticTracing(false) .create(); -setModuleImports("main.mjs", { +setModuleImports('main.mjs', { node: { process: { version: () => globalThis.process.version @@ -23,4 +20,4 @@ const exports = await getAssemblyExports(config.mainAssemblyName); const text = exports.MyClass.Greeting(); console.log(text); -await runMainAndExit(config.mainAssemblyName, ["dotnet", "is", "great!"]); +await dotnet.run(); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmTemplateTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmTemplateTests.cs index 34b2405560003..1d73b75894cc7 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmTemplateTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmTemplateTests.cs @@ -51,8 +51,7 @@ private void UpdateConsoleMainJs() string mainJsContent = File.ReadAllText(mainJsPath); mainJsContent = mainJsContent - .Replace(".create()", ".withConsoleForwarding().create()") - .Replace("[\"dotnet\", \"is\", \"great!\"]", "(await import(/* webpackIgnore: true */\"process\")).argv.slice(2)"); + .Replace(".create()", ".withConsoleForwarding().create()"); File.WriteAllText(mainJsPath, mainJsContent); }