Description
openedon May 12, 2022
Description
Summary: Cannot initialize dotnet runtime except at location AppBundle
directory.
In the template, we can run the sample code by executing the following command in the directory where the assets exist after the build (AppBundle).
$ node main.cjs
Then, from one directory up, run main.cjs in the following way to cause Failed to load config file ./mono-config.json Error: ENOENT: no such file or directory, open './mono-config.json'
I expected to find mono-config.json
in the same path as the execution path, so I explicitly specified the path and it was successfully loaded.
The modified code is as follows...
const createDotnetRuntime = require("./dotnet.js");
const { resolve } = require("path");
async function main() {
const { MONO } = await createDotnetRuntime({
configSrc: resolve(__dirname, "mono-config.json"),
});
const app_args = process.argv.slice(2);
await MONO.mono_run_main_and_exit("console.dll", app_args);
}
main();
But an error MONO_WASM: Error in mono_download_assets: Error: MONO_WASM: Fetch 'supportFiles/0_runtimeconfig.bin' for supportFiles/0_runtimeconfig.bin failed undefined undefined
occurred.
Reproduction Steps
- dotnet new wasmconsole
- replace main.cjs with Snippet1 (below)
- dotnet publish -c Release
- cd bin/Release/net7.0/browser-wasm
- node AppBundle/main.cjs
Snippet1
const createDotnetRuntime = require("./dotnet.js");
const { resolve } = require("path");
async function main() {
const { MONO } = await createDotnetRuntime({
configSrc: resolve(__dirname, "mono-config.json"),
});
const app_args = process.argv.slice(2);
await MONO.mono_run_main_and_exit("console.dll", app_args);
}
main();
Expected behavior
When initializing the dotnet runtime, it is possible to load assets other than assembly and resource even if the node runtime path is not the same path.
see:
runtime/src/mono/wasm/runtime/startup.ts
Lines 511 to 520 in 51d51c1
Actual behavior
Only assembly can be resolved by path and cannot load vfs behavior file.
Regression?
No response
Known Workarounds
No response
Configuration
- OS
- macOS 12.3.1(21E258)
- dotnet --version
- 7.0.100-preview.4.22252.9
- Node
- v16.13.0
Other information
[2022-05-12T14:11:53.081Z] Worker process started and initialized.
[2022-05-12T14:11:54.118Z] Host lock lease acquired by instance ID '000000000000000000000000A572DD4C'.
[2022-05-12T14:13:04.993Z] Worker process started and initialized.
[2022-05-12T14:13:08.343Z] Executing 'Functions.HttpTrigger' (Reason='This function was programmatically called via the host APIs.', Id=f7e37082-4d19-45b3-ab6a-bebe8f2398e0)
[2022-05-12T14:13:08.362Z] HTTP trigger function processed a request.
[2022-05-12T14:13:08.366Z] {
[2022-05-12T14:13:08.366Z] assembly_root: 'managed',
[2022-05-12T14:13:08.366Z] debug_level: 0,
[2022-05-12T14:13:08.366Z] assets: [
[2022-05-12T14:13:08.366Z] { behavior: 'assembly', name: 'console.dll' },
[2022-05-12T14:13:08.366Z] { behavior: 'assembly', name: 'System.Console.dll' },
[2022-05-12T14:13:08.366Z] { behavior: 'assembly', name: 'System.Private.CoreLib.dll' },
[2022-05-12T14:13:08.367Z] {
[2022-05-12T14:13:08.367Z] behavior: 'assembly',
[2022-05-12T14:13:08.367Z] name: 'System.Private.Runtime.InteropServices.JavaScript.dll'
[2022-05-12T14:13:08.367Z] },
[2022-05-12T14:13:08.367Z] { behavior: 'assembly', name: 'System.Private.Uri.dll' },
[2022-05-12T14:13:08.367Z] { behavior: 'assembly', name: 'System.Runtime.dll' },
[2022-05-12T14:13:08.367Z] {
[2022-05-12T14:13:08.367Z] virtual_path: 'runtimeconfig.bin',
[2022-05-12T14:13:08.367Z] behavior: 'vfs',
[2022-05-12T14:13:08.367Z] name: 'supportFiles/0_runtimeconfig.bin'
[2022-05-12T14:13:08.367Z] },
[2022-05-12T14:13:08.367Z] { load_remote: false, behavior: 'icu', name: 'icudt.dat' },
[2022-05-12T14:13:08.367Z] {
[2022-05-12T14:13:08.367Z] virtual_path: '/usr/share/zoneinfo/',
[2022-05-12T14:13:08.367Z] behavior: 'vfs',
[2022-05-12T14:13:08.367Z] name: 'dotnet.timezones.blat'
[2022-05-12T14:13:08.367Z] }
[2022-05-12T14:13:08.367Z] ],
[2022-05-12T14:13:08.367Z] remote_sources: [],
[2022-05-12T14:13:08.367Z] environment_variables: {},
[2022-05-12T14:13:08.367Z] runtime_options: [],
[2022-05-12T14:13:08.367Z] globalization_mode: 'auto',
[2022-05-12T14:13:08.367Z] diagnostic_tracing: false
[2022-05-12T14:13:08.368Z] }
[2022-05-12T14:13:08.368Z] '/Users/yk-yamada/Projects/github.com/yamachu/azure-functions-nodejs-with-csharp/dist/AppBundle/managed/console.dll' <- behavior: assembly
[2022-05-12T14:13:08.380Z] 'supportFiles/0_runtimeconfig.bin' <- behavior: vfs
[2022-05-12T14:13:08.382Z] 'icudt.dat' <- behavior: vfs
[2022-05-12T14:13:08.384Z] 'dotnet.timezones.blat' <- behavior: vfs
I think we can run locateFile
on any file type, but what is the reason for narrowing down the types?
runtime/src/mono/wasm/runtime/startup.ts
Lines 511 to 520 in 51d51c1