Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Jan 22, 2026

This PR allows to use dotnet.js directly from runtime pack similar way as dotnet.exe run

Motivation: V8 is a "naked" JS engine. We use it to run microbenchmarks.

The challenge with V8 is that doesn't give us the directory listing feature of the OS.
So we have to first create file dotnet.assets.txt that the V8 could read list of DLLs.

PS D:\> node dotnet.js
usage: v8 --module dotnet.js -- hello.dll arg1 arg2
usage: node dotnet.js HelloWorld.dll arg1 arg2

PS D:\> node dotnet.js HelloWorld.dll a b c d
Hello, World!

PS D:\> v8 --module dotnet.js
usage: v8 --module dotnet.js -- hello.dll arg1 arg2
usage: node dotnet.js HelloWorld.dll arg1 arg2

PS D:\> v8 --module dotnet.js -- HelloWorld.dll a b c d
Shell/V8 can't list files in the current directory.
Please generate an 'dotnet.assets.txt' file with the list of files to load.
Depending on your shell, you can use one of the following commands:
  Get-ChildItem -Name > dotnet.assets.txt
  dir /b > dotnet.assets.txt
  ls > dotnet.assets.txt

PS D:\> Get-ChildItem -Name > dotnet.assets.txt
PS D:\> v8 --module dotnet.js -- HelloWorld.dll a b c d
Hello, World!

Alternatively you can always use our WASM SDK, to create full application manifest (with all the DLLs and other config) and embed it directly into dotnet.js.

Or alternatively import { dotnet } from './_framework/dotnet.js' as a library and use it's host builder API.

Or alternatively even more stripped corerun, that works only with NodeJS

PS D:\> node .\corerun.js /HelloWorld.dll a b c
Hello, World!

Fixes #120208
Both A1) and A2)

@pavelsavara pavelsavara added this to the 11.0.0 milestone Jan 22, 2026
@pavelsavara pavelsavara requested a review from maraf January 22, 2026 16:57
@pavelsavara pavelsavara self-assigned this Jan 22, 2026
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Jan 22, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Love the idea. Thanks!

pavelsavara and others added 12 commits January 22, 2026 19:46
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
# Conflicts:
#	src/native/corehost/browserhost/loader/exit.ts
@pavelsavara
Copy link
Member Author

In short discussion with Maraf yesterday, he expressed that self-configuration V8 (and maybe NodeJS) use-case is moot.
And that we are always better off with WASM-SDK putting together the application folder and application manifest.

That's the methods isNodeHosted, isShellHosted, shellFindResources, nodeFindResources, findResources.
I'm happy to delete that self-configuration code, so that we don't have to maintain it.
On the other hand, it's just 100 lines.
The rest of this PR is enabling V8 in WASM-SDK scenario and I want to merge it.

It's fair to say that for R2R or linking any native C library we actually need WASM-SDK.
We will be using WASM-SDK even for microbenchmarks.
This idea only works for full MSIL interpreter, in very default configuration.

My use-cases for that self-configuration from current directory are mostly about lowering the bar of exploration and adoption.

  • For (coreCLR VM) people, who don't want to use that MsBuild/WASM-SDK to be able to quickly try to run some app.
  • maybe for someone who wants to package the wasm dotnet runtime as NPM package (without shipping dotnet SDKs).

What do you think @maraf @radekdoulik @lewing @AaronRobinsonMSFT

@pavelsavara
Copy link
Member Author

I introduced browserVirtualAppBase constant(s) to unify in which directory of the VFS the application runs.

I made it to be /managed folder consistently.
In NodeJS this allows us to mount current directory of the host into it.

For Mono it was / until now, unless someone specified virtualWorkingDirectory in the manifest.
I changed that to /managed too, to see what would happen/break.

I also changed the default TargetPath of <WasmFilesToIncludeInFileSystem> to be relative to that, when not specified.

@maraf please let's talk about this

@pavelsavara
Copy link
Member Author

pavelsavara commented Jan 28, 2026

In short discussion with Maraf yesterday, he expressed that self-configuration V8 (and maybe NodeJS) use-case is moot.

We had chance to discuss at length with @maraf this morning.

TL;DR: the self-configuring CLI experience doesn't make much sense outside of simplest demo. Use WASM SDK!

  • to create NPM package out of runtime pack would work, but
  • it's only useful with pure IL assembly that has some Main()
  • mostly only with NodeJS, not with V8, because console app without FS is not very useful.
  • in most environments, as a customer, you can use OS-native dotnet run instead
  • the use-case of using the npm package + our JS host API would work
  • but you can't really call into managed code without JSExport.
  • Module.ccall into UnmanagedCallerOnly is possible, but quite low-level experience
  • you are better off with WASM SDK, and so, you don't need the self-configuration

I will close this PR, take the V8 polyfill and other useful bits of this PR and create another PR.

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

Labels

arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][coreCLR] use WasmAppHost -> WasmTestRunner to run library tests

2 participants