Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 19, 2022 06:31 am GMT

Suppress runtime relinking at publishing Blazor WebAssembly apps

Backgounds

After installing ".NET WebAssembly build tools", runtime relinking will be performed automatically whenever you publish Blazor WebAssembly apps in the "Release" configuration.

The install option of ".NET WebAssembly build tools"

Runtime relinking reduces the size of "dotnet.wasm" by trimming unused runtime code.

That size reduction will contribute download speed of Blazor WebAssembly apps.

The size of "dotnet.wasm" before and after installing ".NET WebAssembly build tools"

See also following links for more details.

However, runtime relinking will take a bit long time for publishing.

Of course, this will not matter for almost developers.

But in some rare cases, taking time for runtime relinking annoys developers, particularly when they investigate a problem involved with the publishing process.

Solution

Fortunately, we can suppress runtime relinking manually.

What we have to do is just specifying the "UsingBrowserRuntimeWorkload" MSBuild property to "false".

For example, you can do that with the command line arguments of dotnet publish command.

dotnet publish -c:Release -p:UsingBrowserRuntimeWorkload=false

That command behaves like ".NET WebAssembly build tools" is not installed, so the publishing process finishes faster than the case that runtime relinking is performed.

Compare publishing speed with and without "-p:UsingBrowserRuntimeWorkload=false"

Limitation

Setting the "UsingBrowserRuntimeWorkload" MSBuild property to "false" is available only when the Blazor WebAssembly project doesn't use the "Native Dependency" feature.

If the Blazor WebAssembly project depends on the "Native Dependency" feature, the building and publishing process should be failed.


Original Link: https://dev.to/j_sakamoto/suppress-runtime-relinking-at-publishing-blazor-webassembly-apps-mc1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To