Change extension of ICU files in .NET on WASM app
https://maraf.github.io/dotnet-wasm-rename-icu/
- Install .NET 8 SDK (RC1)
- Install wasm-tools workload
dotnet workload install wasm-tools
- Run the project
dotnet run
The solution consists of two parts
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<!-- π New extension for ICU files -->
<NewIcuFileExtension>.icu</NewIcuFileExtension>
</PropertyGroup>
...
<!-- π After the application is build/published -->
<Target Name="RenameIcuToAppBundle" AfterTargets="WasmBuildApp;WasmNestedPublishApp">
<ItemGroup>
<!-- π Find all ICU files in AppBundle -->
<IcuFiles Include="$(WasmAppDir)\**\*.dat" />
</ItemGroup>
<!-- π Change their extension to 'NewIcuFileExtension' -->
<Move SourceFiles="@(IcuFiles)"
OverwriteReadOnlyFiles="true"
DestinationFiles="%(RelativeDir)%(Filename)$(NewIcuFileExtension)" />
</Target>
</Project>
... = await dotnet
// π Override resource URL resolution
.withResourceLoader((type, name, defaultUri, integrity) => {
// π Override extension of ICU files
if (type == 'globalization') {
defaultUri = defaultUri.replace('.dat', '.icu');
}
return defaultUri;
})
.create();