DEV Community

jsakamoto
jsakamoto

Posted on

3 1

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

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

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
Enter fullscreen mode Exit fullscreen mode

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

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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more