Repository navigation
[wasm][CoreCLR] Unify packaged application launch arguments - #137503
Draft
pavelsavara wants to merge 4 commits into
Draft
pavelsavara wants to merge 4 commits into
pavelsavara wants to merge 4 commits into
Conversation
Separate .NET environment and runtime-property overrides from application arguments across Node, Browser, JavaScript shells, and WASI. Restore the manifest-backed Node self-starter without assembly discovery, preserve argument boundaries, and use transient Browser launch configuration. Fix the SDK WASI host layout and Windows linking paths needed to exercise the same contract. Add focused parser and real packaged-app regressions. Co-authored-by: Copilot <[email protected]>
Preserve upstream's appsettings byte/file loading and the packaged-app launch argument overrides and Node self-starter. Co-authored-by: Copilot <[email protected]>
Combine the launch URL, browser path, and additional query parameters without dropping asset selection or duplicating inherited queries. Cover query escaping, fragments, repeated arguments, and actual browser navigation alongside the packaged CLI regressions. Co-authored-by: Copilot <[email protected]>
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Nov 13, 2026
Adapt WASI launch overrides to the embedded runtime configuration from upstream/main. Keep host and explicit launch properties ahead of embedded defaults when initializing CoreCLR. Remove the PR's runtime-flavor metadata and Mono compatibility paths. Use the supported CoreCLR WASI bundle layout directly without restoring or extending the retired Mono runtime. Co-authored-by: Copilot <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Define a consistent launch-argument contract for SDK-produced CoreCLR WebAssembly applications across Node.js, JavaScript shells, Browser, and WASI. Separate .NET launch configuration from managed application arguments without retaining the historical Mono argument conventions.
Updated on November 24: merge current
mainthrougha9ffa6f8b33cin085293591f7d. The supported implementation is CoreCLR-only. Mono is retired, unsupported, and not built; this PR does not add or preserve a Mono compatibility layer. Active Browser/WASI SDK and launcher code still resides undersrc/mono.Restore the historical Node entry-script detection and
runMainAndExitpath, but do not restore resource discovery. The app still uses its SDK-generated embedded boot configuration or WASI bundle. There are no CoreRun source changes, no assembly-directory scanning, and no new general-purpose managed-assembly runner.Behavior changes
dotnet.jsexported/configured a builder but did not automatically invoke managedMain.dotnet.jsdirectly starts its configured entry assembly and propagates the managed exit code.dotnet runforwarding--dotnet-*options configure environment/runtime properties; the first ordinary argument or--starts the opaque application argument tail.process.envoverrides packaged/builder environment values; explicit launch assignments overrideprocess.env. Launch property/environment overrides are reapplied after config-loaded initializers.runArgs.jsoninto the output and also placed application arguments in the URL.Cache-Control: no-store; its address is included in the printed application URL. No per-run configuration file is written.arg=values remain literal application arguments, including on a published app without a development endpoint.wasihostinmanaged/corerunwith the packaged entry assembly and required engine defaults. Use the supported CoreCLR layout directly, without runtime-flavor metadata, detection, or Mono fallback paths.mainembeds generated runtime configuration in the per-app native host.runtimeconfig.binloading.BrowserPath, breaking the cache-seeding tests.These are intentional behavioral changes in the active CoreCLR hosting and SDK plumbing. The latest merge removes this PR's WASI runtime-flavor task input, generated flavor metadata, and Mono single-file/legacy-module fallback paths.
WasiAppBuilder.csandWasiApp.targetsno longer have PR-specific changes relative tomain; no Mono runtime sources are changed.Detailed usage
Common grammar
--dotnet-*options are interpreted.--ends .NET launch-option parsing. Further--tokens are ordinary application arguments.=.=after the name; an empty value is permitted.--dotnet-helpprints launcher usage without running managedMain; ordinary--helpbelongs to the application.Node.js: packaged application
Run from the published app's
wwwrootdirectory, adjusting the path for the app's output layout:The second command delivers
["--input", "data.txt"]to managedMain. The application and its dependencies are selected by the embedded boot configuration, not by probing the filesystem for assemblies.An application argument that looks like a launcher option must be escaped with the boundary:
Managed arguments:
["--dotnet-env=literal", "--", ""].dotnet run: same application contractThe first
--belongs to the .NET SDK and is consumed there. The optional second boundary belongs to the .NET application launcher. WasmAppHost's own internal boundary is generated by the build targets and is not something users need to supply.Choose a configured host independently of application arguments:
Here
nodeandbrowserare names inwasmHostProperties.perHostConfig, not new SDK switches.--debugand--host=...in the application tail are application arguments, not WasmAppHost controls.Engine flags and custom JavaScript startup
Engine options remain before the engine's entry script:
For
dotnet run, use the host configuration'shost-args, or the existingWasmHostArguments/--extra-host-argmechanism. Engine switches are not added to the shared .NET launch grammar.Applications requiring JavaScript setup still import the builder:
Importing alone does not run
Main. The explicit launch value wins over the builder default. JavaScript shells consumescriptArgsorargumentsusing the same launch grammar; V8 was exercised through a custom ES module bootstrap rather than an automatically detected shell entry point. This draft restores automatic direct-entry execution for Node, not a universal shell self-starter.Browser
The Browser host uses the same
dotnet run -- ...grammar. Open the printed application URL, preserving itsdotnet-launchparameter. The loader fetches that same-origin launch configuration before starting the runtime. CLI environment/runtime-property overrides win over packaged defaults, builder configuration, and config-loaded initializers.The development server's inherited environment is not forwarded wholesale. In particular, do not assume SDK
dotnet run -e NAME=VALUEreaches the Browser guest; use--dotnet-env=NAME=VALUEfor this portable contract.Published apps without
dotnet-launchdo not make an extra launch-configuration request. Their repeated?arg=...&arg=...parameters are literal application arguments, not .NET launcher switches. Explicitarg=values take precedence over the application argument array in the launch payload.WASI
From the SDK-generated CoreCLR WASI bundle directory:
managed/corerunis the SDK's per-app linked wasihost, not the CoreRun development runner. The assembly argument is part of the existing packaged WASI layout; it does not introduce assembly discovery.From the project directory:
WasmAppHost supplies the packaged host/assembly arguments and the CoreCLR engine defaults. Wasmtime flags still belong before the module filename.
Runtime properties generated from the project are compiled into the per-app WASI host. For example, a packaged
MyApp.Modevalue remains the default with no override; passing'--dotnet-runtime-property=MyApp.Mode="launch"'overrides it for that invocation. No runtime-flavor field orruntimeconfig.binis needed.Implementation and migration notes
selfHostNodeJS/isNodeHostedfrom the historical loader design withoutfindResources.runArgs.jsonwriting and the unused host-side runtime-argument property. Replace legacy Mono option strings with environment variables or supported CoreCLR runtime configuration properties.WasmHostArgumentsor host configuration; application--help,--debug, and--hostno longer configure the outer launcher.--dotnet-*after an explicit--.main's current embedded WASI runtime configuration instead of bringing back the old binary-file reader. Explicit launch values take precedence over generated defaults.src/monoare active CoreCLR SDK, launcher, documentation, and test code; there is no attempt to build or support the retired runtime.Validation
Latest merge validation (November 24)
Validated the merged
085293591f7dsource locally on Windows, CoreCLR Debug. Browser and WASI builds were serialized in the same worktree. No Mono build or test was attempted.Commands below ran from the worktree root unless noted.
.\build.cmd -bl -os browser -subset clr+libs+host -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false.\build.cmd -bl -os wasi -subset clr+libs+host -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false.\dotnet.cmd pack -bl:artifacts\log\cli-nov24-sdk-pack.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:Configuration=Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false .\src\mono\nuget\Microsoft.NET.Sdk.WebAssembly.Pack\Microsoft.NET.Sdk.WebAssembly.Pack.pkgproj.\dotnet.cmd build -bl:artifacts\log\cli-nov24-regressions-final.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:Configuration=Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:TestUsingWorkloads=false /p:InstallWorkloadForTesting=false /p:XUnitClassName=Wasm.Build.Tests.MainWithArgsTests /t:Test .\src\mono\wasm\Wasm.Build.Testsnpx --no-install eslint --no-color --max-warnings=0 libs\Common\JavaScript\loader\launch.ts libs\Common\JavaScript\loader\bootstrap.ts libs\Common\JavaScript\loader\dotnet.ts libs\Common\JavaScript\loader\host-builder.ts libs\Common\JavaScript\loader\run.ts libs\Common\JavaScript\host\index.ts(fromsrc\native)git diff upstream/main HEAD --checkThe 17-test run covers direct Node startup/exit, no-argument startup, import-only behavior, custom JS startup, SDK forwarding, exact empty/Unicode/space/
=/separator arguments, environment/property precedence, duplicate assignments, invalid options, help, Browser launch endpoint/cache headers, and the published Browser path without an extra launch request. Five focused URL cases cover the previous cache-seeding regression; the real Browser run additionally asserts that the launch URL,BrowserPath, and extra query parameters all survive.A temporary in-tree SDK-created WASI app was published with:
Result: passed. Actual
dotnet run --no-build -c Debug -p:TargetOS=wasi -p:TargetArchitecture=wasm -p:RuntimeFlavor=CoreCLR -- ...checks then passed both with no launch overrides and with repeated string-property overrides, a boolean override, and an environment assignment. They verified:Cli.Property=packaged/Cli.Flag=falsedefaults remain intact without overrides.--, namespaced-looking application arguments, and Unicode arrive exactly.42is preserved.runtimeconfig.binare required.The temporary app was removed after validation.
The first local test attempt found missing .NET 12 host frameworks in the older constructed test SDK. Installed only the missing .NET/ASP.NET frameworks into that isolated SDK, then selected the already-restored current XHarness through the supported process-local
XHARNESS_CLI_PATHsetting. The final 17-test run passed; no user or machine environment settings were changed.Not rerun for this merge: JavaScriptCore, SpiderMonkey, V8, Linux/macOS, Release, full suites, or the Blazor asset-caching class. The latter was previously blocked locally by NuGet audit errors in its pre-existing server dependency; the November 13 CI results did confirm both formerly failing caching methods pass on Windows and Linux after the URL fix. JavaScriptCore/SpiderMonkey handler registration is compiled but not runtime-validated.
Earlier validation
The original direct-Node regression was observed against the baseline: the loader exited
0without running the app instead of returning the app's42. Three of the new URL cases also failed before the query-composition fix.Earlier iterations passed a focused Chrome JS-interop library smoke test, 16 appsettings tests after the November 6 merge, and real V8/Wasmtime launches with exact argv/environment/property/exit-code assertions. V8 used the repository's existing test-only crypto shim and a short path to avoid the installed engine's Windows path-length limitation. These historical checks are not claimed as rerun on the latest merge.
An exploratory in-process BenchmarkDotNet run measured the managed parser at approximately 38 ns / 208 B for no arguments and 752 ns / 1,192 B for one environment plus one runtime-property override. Timing confidence intervals were wide; these are absolute parser costs, not a baseline comparison or an end-to-end startup-performance claim.
Repository migration
Replaces dotnet/runtime#137002. Continue review and publication on
dotnet/runtimebranchpavelsavara/browser-coreclr-cli-arguments, not the original fork branch. The branch was initially copied ate5da3de3d36; the latest merge/cleanup is085293591f7d.Resolves #88760
Note
This pull request and its description were generated with GitHub Copilot.