-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tracking] Publish .NET assemblies in Webcil files #80807
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsFollow-up to #79416
|
Code review nits:
|
|
WebCIL is a new container format for .NET assemblies used when publishing WebAssembly apps (see dotnet/runtime#79416) Related to dotnet/runtime#80807
WebCIL is a new container format for .NET assemblies when publishing to webassembly. (See dotnet/runtime#79416) Related to dotnet/runtime#80807
WebCIL is a new container format for .NET assemblies used when publishing WebAssembly apps (see dotnet/runtime#79416) Related to dotnet/runtime#80807
WebCIL is a new container format for .NET assemblies when publishing to webassembly. (See dotnet/runtime#79416) Related to dotnet/runtime#80807
WebCIL is a new container format for .NET assemblies when publishing to webassembly. (See dotnet/runtime#79416) Related to dotnet/runtime#80807
WebCIL is a new container format for .NET assemblies when publishing to webassembly. (See dotnet/runtime#79416) Related to dotnet/runtime#80807
As technically impressive as this work may be, it's an extensive workaround to the current blazor inadequacy of deploying dlls to user systems rather than compiling everything to WASM. Full compilation (via a fix to Mono WASM AOT or NativeAOT) will make this obsolete unless it finds some other application than browsers. |
Re @charlesroddie's point. ☝️ Does the creation of |
Maybe a bit of a dumb question, so sorry in advance, but if I'm using this new format, what will my dev tools Network tab look like if I do a hard reload? Will I see a ton of files being downloaded like I do now (the equivalent of the .dll's) or just one big webcil file? What will the MIME type be? |
Is it possible to try out the new WebCIL file format in Preview 1 of dotnet 8? We would like to get feedback from our customers as quickly as possible to determine whether this new format solves the firewall problems in our environment. Is there any documentation or how-to guide on how to create a Hello World Blazor WebAssembly application using the new WebCLI format? |
@Schaeri Webcil doesn't work with blazor yet - that's coming in a future .NET 8 Preview. You can try it out by building a <PropertyGroup>
<WasmEnableWebcil>true</WasmEnableWebcil>
</PropertyGroup> Something like this will work: $ dotnet workload install wasm-tools
$ dotnet workload install wasm-experimental
$ dotnet new wasmbrowser
$ dotnet publish -c Release -p:WasmEnableWebcil=true Now serve the Please let us know whether it is working or not. If it doesn't work, it woudl be great to know what AV tool is being used and how it is configured (please ping me - we can discuss in private, if necessary) |
I would think bundling would hit loading performance for Blazor? It couldn't begin loading until its got the full bundle rather than logical smaller files. In a https/2 or 3 world i'm not sure of the benefits of a bundle. There could be some opportunities to reduce the perceived loading time of Blazor by partitioning files independently of dll structure. Blazor could download an initial webcil file containing the classes necessary to begin loading. Other webcil files download in the background and are hopefully obtained before they are needed as the site loads. Essentially a lazy loading process not bound by dll boundaries. I think you will get more testers once its available for Blazor Wasm. |
The small demo using webcil worked for us. Working with 2 companies that have ZScaler enabled, and both have an issue where blazor WASM projects don't load. Need to have a solution for this before we can continue. |
BlazorWasmAntiVirus doesn't work for you? |
No, unfortunately it put my project in a state where it was just error after error. Spent way too many hours trying to recover afterwards. |
@rffsgate I have experienced the same on development machines. Sadly it is a known issue that the author is unable to fix. The workaround for us is to only use it in release builds, where it doesn't seem to be a problem. |
Thanks @paulguz-datapa, at least I know I am not going nuts. Very frustrating. |
WebCIL is a new container format for .NET assemblies when publishing to webassembly. (See dotnet/runtime#79416) Related to dotnet/runtime#80807
I've tried running this today using .Net 8 Preview 3. The publish fails with the following, after a long pause:
There is no AppBundle folder. There is a 'publish' folder, but I get a JS error from dotnet.js if I run 'dotnet run' in that folder. The embuilder error looks like a known issue that may well be fixed in Preview 4. |
@lambdageek: We received the first feedback from our three largest customers, who blocked our application even with the currently available workarounds. The feedback was positive, for two out of three the first .Net 8.0 preview webcil sample worked. The blocking had nothing to do with the WebCil. The Azure URL for our test seems to be on a blacklist. The Webcil solution seems to be promising. We hope for more feedback, as soon as we hear more we will report it here again. |
Hey folks, Just want to highlight something that we're currently working on with webcil. Our updated plan is to wrap the webcil payload in a WebAssembly module. The upshot is that a browser-based .NET WebAssembly app, we will consist of:
In addition to the usual The rationale is that we want to be in a situation where we only serve standard web app MIME types and file extensions: As an implementation note, the webcil-in-wasm modules will export a pair of functions The updated Webcil spec and implementation are in #85932 the goal is to land this in an upcoming .NET 8 Preview after Preview 4 is out. (That is, Preview 4 will not have webcil-in-wasm - it will have webcil as .webcil same as earlier previews) |
@jeromelaban @MikeCodesDotNET @maxkatz6 FYI ^^^ #80807 (comment) In .NET 8, we're going to change how we package .NET assemblies for the browser. For Blazor this affected some of their publishing support around lazy loading #85400, so you may also need to react in some way (or opt out)
|
Thanks for the heads up! We really appreciate you letting us know of a potential issue for us. We'll investigate it this week and see what we need to do on our side. |
Define a WebAssembly module wrapper for Webcil assemblies. Contributes to #80807 ### Why In some settings serving `application/octet-stream` data, or files with weird extensions will trigger firewalls or AV tools. But let's assume that if you're interested in deploying a .NET WebAssembly app, you're in an environment that can at least serve WebAssembly modules. ### How Essentially we serve this WebAssembly module: ```wat (module (data "\0f\00\00\00") ;; data segment 0: payload size (data "webcil Payload\cc") ;; data segment 1: webcil payload (memory (import "webcil" "memory") 1) (global (export "webcilVersion") i32 (i32.const 0)) (func (export "getWebcilSize") (param $destPtr i32) (result) local.get $destPtr i32.const 0 i32.const 4 memory.init 0) (func (export "getWebcilPayload") (param $d i32) (param $n i32) (result) local.get $d i32.const 0 local.get $n memory.init 1)) ``` The module exports two WebAssembly functions `getWebcilSize` and `getWebcilPayload` that write some bytes (being the size or payload of the webcil assembly) to the linear memory at a given offset. The module also exports the constant `webcilVersion` to version the wrapper format. So a runtime or tool that wants to consume the webcil module can do something like: ```js const wasmModule = new WebAssembly.Module (...); const wasmMemory = new WebAssembly.Memory ({initial: 1}); const wasmInstance = new WebAssembly.Instance(wasmModule, {webcil: {memory: wasmMemory}}); const { getWebcilPayload, webcilVersion, getWebcilSize } = wasmInstance.exports; console.log (`Version ${webcilVersion.value}`); getWebcilSize(0); const size = new Int32Array (wasmMemory.buffer)[0] console.log (`Size ${size}`); console.log (new Uint8Array(wasmMemory.buffer).subarray(0, 20)); getWebcilPayload(4, size); console.log (new Uint8Array(wasmMemory.buffer).subarray(0, 20)); ``` ### How (Part 2) But actually, we will define the wrapper to consist of exactly 2 data segments in the WebAssembly data section: segment 0 is 4 bytes and encodes the webcil payload size; and segment 1 is of variable size and contains the webcil payload. So to load a webcil-in-wasm module, the runtime gets the _raw bytes_ of the WebAssembly module (ie: without instantiating it), and parses it to find the data section, assert that there are 2 segments, ensure they're both passive, and get the data directly from segment 1. --- * Add option to emit webcil inside a wasm module wrapper * [mono][loader] implement a webcil-in-wasm reader * reword WebcilWasmWrapper summary comment * update the Webcil spec to include the WebAssembly wrapper module * Adjust RVA map offsets to account for wasm prefix MonoImage:raw_data is used as a base when applying the RVA map to map virtual addresses to physical offsets in the assembly. With webcil-in-wasm there's an extra wasm prefix before the webcil payload starts, so we need to account for this extra data when creating the mapping. An alternative is to compute the correct offsets as part of generating the webcil, but that would entangle the wasm module and the webcil payload. The current (somewhat hacky approach) keeps them logically separate. * Add a note about the rva mapping to the spec * Serve webcil-in-wasm as .wasm * remove old .webcil support from Sdk Pack Tasks * Implement support for webcil in wasm in the managed WebcilReader * align webcil payload to a 4-byte boundary within the wasm module Add padding to data segment 0 to ensure that data segment 1's payload (ie the webcil content itself) is 4-byte aligned * assert that webcil raw data is 4-byte aligned * add 4-byte alignment requirement to the webcil spec * Don't modify MonoImageStorage:raw_data instead just keep track of the webcil offset in the MonoImageStorage. This introduces a situation where MonoImage:raw_data is different from MonoImageStorage:raw_data. The one to use for accessing IL and metadata is MonoImage:raw_data. The storage pointer is just used by the image loading machinery --------- Co-authored-by: Larry Ewing <[email protected]>
Hello everyone, Webcil has now been turned on by default for Blazor WebAssembly projects in .NET 8 Preview 5. Blazor apps should now consist entirely of .js .wasm, .html and .css files. No more .dlls. If you previously had problems running Blazor WASM apps due to firewalls or AV software, please try building with P5 and let us know how it goes. I am interested both in successes and failures. If it's working, let me know. If it's not working, definitely let me know |
@mihaimyh I believe you mentioned elsewhere that you're interested in a solution to Blazor WebAssembly apps getting blocked by proxy or antivirus software. Have you had a chance to give the new webcil packaging a try in .NET 8 Preview 5? Did it resolve any issues you may have been seeing? |
Hi @danroth27 I have tried webcil packaging with .NET 8 preview, and indeed, it solved antivirus blocking the download of the application binaries. Looking forward for .NET 8 release date. |
Thanks for the updates. I can also confirm that this worked for our organisation. Zscaler and AV didn't block it this time. |
I can confirm that this works with G DATA Internet Security. Thanks for your work on this. |
I can also confirm Sophos AV. |
@lambdageek I think we can close this and let the transport feed issue stay open |
Summary
Webcil is a new container format for .NET assemblies that looks less like a normal Windows PE (Portable Executable) .dll file.
A .NET assembly in the Webcil format is a normal binary WebAssembly module with a particular set of exports that will copy a "Webcil payload" to WebAssembly linear memory.
It has
a newa standard.webcil
extensionapplication/wasm
MIME type and.wasm
extension and the detailed format is specified in webcil.md.There are two primary motivations for webcil:
.dll
or PE files, and some AV tools may quarantine.dll
files found in browser caches..NET 8 Preview 1
The goal is to make Webcil work in the
wasm-experimental
workload with thewasmbrowser
templateThe initial runtime work was done in #79416
WebcilReader.ReadPdbChecksumDebugDirectoryData
and refactor DebugStoreAssemblyInfo.FromWebcilReader
andAssemblyInfo.FromPEReader
to share PDB logic (maybe using a newIDebugInfoProvider
adapter to cover the common parts of PE and Webcil) BrowserDebugProxy: unify debug metadata reading for PE and Webcil #81099Later in .NET8
BugRegression_60479_WithRazorClassLib
)dotnet new wasmbrowser
) and Blazor WebAssembly apps (dotnet new blazorwasm
) [wasm] Set WasmEnableWebcil to true by default #86330Post .NET 8
Other
The text was updated successfully, but these errors were encountered: