Blazor how to generate that SHA256 check

So ...

I see that Balzor + .NET 5 (where did Core go?!!) is now do have what i want to get my things running but of course as always something was missing, see Blazor lazy loading is just the thing i was looking for but it doesn’t work unless i reference the module/razor component library on the main project, which i exactly what is don't want.

Fortunately this time everything was kind of there, just a bit trouble to do myself.

See if you create a client side Razor app, you get blazor.boot.json file generated and on that file you get lazyAssembly entry which supposed to make browsers only get these assemblies if needed (can't see this working on Firefox or Chrome but that's another story), and if you list your assembly there and follow instructions in here magic happen and the page you created on your razor component library works!

But, first you need to be able to calculate that sha256 value for your assembly!

Which at first i couldn’t figure out how, but then found this Searching that and i found the how to, check this PowerShell code below to generate Blazor sha256 for your assemblies

 


$signature = Get-FileHash -Path "C:\somedir\ClassLibrary1.dll" -Algorithm SHA256
$signatureBytes = [byte[]] -split ($signature.Hash -replace '..', '0x$& ');
$signatureBase64 = [System.Convert]::ToBase64String($signatureBytes);
$signatureBase64

Popular posts from this blog

how to copy NuGet packages from one project to another

How to load a DLL and runtime, invoke a method by name, get result object and use it as a parameter on another unkown DLL .NET Core