Open emepetres opened 3 years ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Author: | emepetres |
---|---|
Assignees: | - |
Labels: | `area-System.IO`, `untriaged` |
Milestone: | - |
Using the item WasmFilesToIncludeInFileSystem to include a file into the wasm vfs does not add it. The file is not shown in FS.root
@marek-safar @akoeplinger what would be the best repo|area for this issue? It seems to be realted to build toolchain rather than System.IO itself
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Author: | emepetres |
---|---|
Assignees: | - |
Labels: | `arch-wasm`, `untriaged` |
Milestone: | - |
hm yeah looks like we don't have a good area tag. /cc @lewing @radical
I noticed that sdk-manifests\6.0.100\microsoft.net.workload.mono.toolchain\WorkloadManifest.targets
sets WasmGenerateAppBundle
to false for blazor project. Therefore _WasmGenerateAppBundle
in /src/mono/wasm/build/WasmApp.targets
is not running. That is, even when I set WasmGenerateAppBundle
to true in my project.
@(WasmFilesToIncludeInFileSystem)
is not used by blazor. It uses @(Content)
items, and that's what the non-blazor projects will start using too.
We should add warnings and notes in the docs for items that don't apply to blazor
So @radical, If I understood correctly, having a file in sample-data/file.txt I guess I should do something like this in blazor:
Directory.CreateDirectory("sample-data");
using (var httpResponse = await httpClient.GetAsync("sample-data/file.txt", HttpCompletionOption.ResponseHeadersRead))
using(var st = await httpResponse.Content.ReadAsStreamAsync())
using (var fs = File.OpenWrite("sample-data/file.txt"))
{
await st.CopyToAsync(fs);
}
var file = File.ReadAllText("sample-data/file.txt");
Console.WriteLine(file);
However it is a shame that emscripten preload is not currently compatible with blazor wasm sdk, any plans to allow it?
Blazor team would be able to answer that best. @captainsafia ?
@javiercn has been playing around with static assets + Blazor which might be relevant here. AFAIK, we don't do anything special for AoT here.
We don't know about the WasmFilesToIncludeInFileSystem
item group, so we don't even look at it.
@lewing in general we want to be good citizens here and make sure we support things like these, we just need to know we need to add them :). We can also work out a mechanic to try and pick these things automagically.
@radical lets add this to the bundler tasks
Description
Using the item
WasmFilesToIncludeInFileSystem
to include a file into the wasm vfs does not add it. The file is not shown in FS.root, and triying to reading it from .Net throws the exceptionSystem.IO.FileNotFoundException: IO_FileNotFound_FileName
.Having a file.txt in the project root, it can be reproduced doing:
csproj
Program.cs
Small sample to reproduce the issue can be found here
Configuration
Using latest runtime sdk 6.0.100-rc.1.21401.2 Using Microsoft.NET.Sdk.BlazorWebAssembly as targets sdk.
Regression?
I guess it worked at some point, as it is being used in some tests.
Other information