[browser] Support WasmFilesToIncludeInFileSystem in WasmSdk#120970
Merged
maraf merged 15 commits intodotnet:mainfrom Oct 31, 2025
Merged
[browser] Support WasmFilesToIncludeInFileSystem in WasmSdk#120970maraf merged 15 commits intodotnet:mainfrom
maraf merged 15 commits intodotnet:mainfrom
Conversation
pavelsavara
reviewed
Oct 22, 2025
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs
Show resolved
Hide resolved
VFS imports were incorrectly generated as "es module" imports, where as they should be treated as "general URL" imports
42 tasks
Open
3 tasks
pavelsavara
reviewed
Oct 27, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for automatically loading files into the WebAssembly Virtual File System (VFS) using the WasmFilesToIncludeInFileSystem item in the WasmSdk. Files specified with this item are loaded into VFS at application startup, with support for custom target paths via TargetPath metadata.
Key Changes:
- Added VFS resource support in boot JSON generation to handle files marked with
vfs:trait - Updated bundler-friendly mode to correctly reference VFS assets with relative paths
- Implemented target path resolution with fallback to file's wwwroot relative path
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/tasks/WasmAppBuilder/WasmAppBuilder.cs |
Updated virtual path prefix to respect RuntimeAssetsLocation |
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs |
Added VFS resource handling in boot config generation |
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs |
Fixed VFS asset path generation for bundler-friendly mode |
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/subdir/subsubdir/Vfs3.txt |
Test file for nested VFS path without custom TargetPath |
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/subdir/Vfs2.txt |
Test file for VFS with custom TargetPath |
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js |
Added test scenario entry point |
src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/Vfs1.txt |
Test file for root-level VFS with custom TargetPath |
src/mono/wasm/testassets/WasmBasicTestApp/App/WasmBasicTestApp.csproj |
Added WasmFilesToIncludeInFileSystem declarations for testing |
src/mono/wasm/testassets/WasmBasicTestApp/App/FilesToIncludeInFileSystemTest.cs |
Test code to verify VFS file existence |
src/mono/wasm/testassets/JavascriptBundlers/rollup.config.mjs |
Updated rollup to handle .txt files |
src/mono/wasm/Wasm.Build.Tests/FilesToIncludeInFileSystemTests.cs |
Integration test for VFS functionality |
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets |
MSBuild integration for WasmFilesToIncludeInFileSystem |
eng/testing/scenarios/BuildWasmAppsJobsList.txt |
Registered new test class for CI |
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs
Show resolved
Hide resolved
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs
Show resolved
Hide resolved
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Outdated
Show resolved
Hide resolved
…sing WasmFilesToIncludeInFileSystem
Member
Author
|
/ba-g Failure is unrelated timeout |
pavelsavara
reviewed
Oct 30, 2025
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs
Show resolved
Hide resolved
pavelsavara
approved these changes
Oct 30, 2025
This was referenced Nov 1, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Use
WasmFilesToIncludeInFileSystemitems to automatically load files to VFS when the application is starting.The identity of
WasmFilesToIncludeInFileSystemneeds to be a relative path to files inwwwroot(either physical or linked). The optionalTargetPathmetadata allows to modify file location in VFS. If the metadata is omitted, a default location will be resolved from relative file path inwwwroot.Example:
wwwroot/file.txtfile<WasmFilesToIncludeInFileSystem Include="file.txt" />will load the file to/file.txt<WasmFilesToIncludeInFileSystem Include="file.txt" TargetPath="/mydata/file.txt" />will load the file to/mydata/file.txtwwwroot/subdir/file.txtfile<WasmFilesToIncludeInFileSystem Include="subdir/file.txt" />will load the file to/subdir/file.txt<WasmFilesToIncludeInFileSystem Include="subdir/file.txt" TargetPath="/mydata/file.txt" />will load the file to/mydata/file.txtWhen `WasmFilesToIncludeInFileSystem` item is missing in StaticWebAssets, build fails (example output)
/workspaces/runtime/artifacts/bin/Wasm.Build.Tests/Debug/net10.0/linux-x64/wbtartifacts/nuget/SatelliteLoadingTestsFromReference_Release_False_st4zw1nv_xij/microsoft.net.sdk.webassembly.pack/10.0.0-dev/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets(353,5): error : Some of the 'WasmFilesToIncludeInFileSystem' where not found in StaticWebAssets. WasmFilesToIncludeInFileSystem: Vfs1.txt;subdir/Vfs2.txt;subdir/subsubdir/Vfs3.txt;NonExistent.txt, matched StaticWebAssets: /workspaces/runtime/artifacts/bin/Wasm.Build.Tests/Debug/net10.0/linux-x64/wbtartifacts/SatelliteLoadingTestsFromReference_Release_False_st4zw1nv_xij/App/wwwroot/Vfs1.txt;/workspaces/runtime/artifacts/bin/Wasm.Build.Tests/Debug/net10.0/linux-x64/wbtartifacts/SatelliteLoadingTestsFromReference_Release_False_st4zw1nv_xij/App/wwwroot/subdir/Vfs2.txt;/workspaces/runtime/artifacts/bin/Wasm.Build.Tests/Debug/net10.0/linux-x64/wbtartifacts/SatelliteLoadingTestsFromReference_Release_False_st4zw1nv_xij/App/wwwroot/subdir/subsubdir/Vfs3.txt [/workspaces/runtime/artifacts/bin/Wasm.Build.Tests/Debug/net10.0/linux-x64/wbtartifacts/SatelliteLoadingTestsFromReference_Release_False_st4zw1nv_xij/App/WasmBasicTestApp.csproj]Fixes #99223