You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On CoreCLR WASI, AppContext.BaseDirectory is /, but the app bundle places the app and framework assemblies under /managed:
wasihost (src/native/corehost/wasihost/wasihost.cpp) sets TRUSTED_PLATFORM_ASSEMBLIES and APP_PATHS (the entry assembly directory, /managed/) but not APP_CONTEXT_BASE_DIRECTORY.
CoreLib then falls back to AppContext.Browser.cs, which is shared with WASI and returns /.
The test harness preopens the bundle directory (--dir=.) and sets CORE_ROOT=/managed.
Code that locates files next to the application therefore looks in the wrong directory. In the CoreCLR WASI library test runs on #134813:
System.Runtime.Loader.Tests: 19 of its 22 failures are FileNotFoundException : Could not find file '/System.Reflection.Metadata.ApplyUpdate.Test...dll', and one more is the same for a System.Runtime.Loader test assembly. The tests build the path from AppContext.BaseDirectory, and the file is in /managed.
System.Diagnostics.TraceSource.Config.Tests (8 of 8): FileNotFoundException : Could not find file '/testhost_ConfigWithRuntime.config'.
Test content deployed through WasmFilesToIncludeInFileSystem lands at the bundle root, not under managed/. So the fix has to keep both working: assemblies located through AppContext.BaseDirectory, and content opened relative to the working directory (/).
Options
Have wasihost set APP_CONTEXT_BASE_DIRECTORY to the entry assembly directory, as other hosts do, and deploy test content into the same directory.
Bundle the assemblies at the root instead of under managed/, so the base directory, working directory and assembly location coincide.
Note
This issue was drafted with the help of GitHub Copilot.
Description
On CoreCLR WASI,
AppContext.BaseDirectoryis/, but the app bundle places the app and framework assemblies under/managed:wasihost(src/native/corehost/wasihost/wasihost.cpp) setsTRUSTED_PLATFORM_ASSEMBLIESandAPP_PATHS(the entry assembly directory,/managed/) but notAPP_CONTEXT_BASE_DIRECTORY.AppContext.Browser.cs, which is shared with WASI and returns/.--dir=.) and setsCORE_ROOT=/managed.Code that locates files next to the application therefore looks in the wrong directory. In the CoreCLR WASI library test runs on #134813:
FileNotFoundException : Could not find file '/System.Reflection.Metadata.ApplyUpdate.Test...dll', and one more is the same for aSystem.Runtime.Loadertest assembly. The tests build the path fromAppContext.BaseDirectory, and the file is in/managed.FileNotFoundException : Could not find file '/testhost_ConfigWithRuntime.config'.Test content deployed through
WasmFilesToIncludeInFileSystemlands at the bundle root, not undermanaged/. So the fix has to keep both working: assemblies located throughAppContext.BaseDirectory, and content opened relative to the working directory (/).Options
wasihostsetAPP_CONTEXT_BASE_DIRECTORYto the entry assembly directory, as other hosts do, and deploy test content into the same directory.managed/, so the base directory, working directory and assembly location coincide.Note
This issue was drafted with the help of GitHub Copilot.