Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly build version at runtime in blazor wasm app

What is the best way to get build version number at runtime in web assembly client-side blazor app? In server side version I was able to use Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.ToString();

Combined with msbump package it was automatically generating new version for me with each new build. Is that possible to achieve at client side blazor too?

like image 511
gp2gp2 Avatar asked Sep 21 '20 21:09

gp2gp2


People also ask

What is AOT in Blazor?

Ahead-of-time (AOT) compilation. Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your . NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size.

How do I deploy Blazor WebAssembly app?

Open Visual Studio 2019 and create a new project. Once Blazor App is selected, click Next button to configure the project name and location. Save the application, and then click Create button. Select Blazor WebAssembly App and click Create button to complete the application creation.

Is Blazor WebAssembly production ready?

Yes, Blazor is ready to be used in production, it is a life changer, Blazor is a framework that optimizes development speed, helps considerably reducing code duplication and inconsistencies between front-end and api/backend models, and in turn it helps reducing bugs and development costs, in top of that, since Blazor ...

What is difference between Blazor server and Blazor WebAssembly?

Blazor Server apps have direct access to server and network resources where the app is executing. Because Blazor WebAssembly apps execute on a client, they don't have direct access to server and network resources.


1 Answers

try using GetExecutingAssembly().

Example:

Assembly.GetExecutingAssembly().
    GetCustomAttribute<AssemblyInformationalVersionAttribute>().
    InformationalVersion;

The reason you can't use the entry assembly is I believe the entry assembly is not your actual assembly. So if you call out for executing assembly you are guaranteed to get your actual assembly.

like image 181
Andy Avatar answered Sep 19 '22 09:09

Andy