Skip to content

Commit cca2859

Browse files
authored
Rename Blazor WASM file extensions (#18129)
1 parent ade6ad3 commit cca2859

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

aspnetcore/host-and-deploy/blazor/webassembly.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to host and deploy a Blazor app using ASP.NET Core, Conte
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/30/2020
8+
ms.date: 05/04/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: host-and-deploy/blazor/webassembly
1111
---
@@ -394,3 +394,53 @@ A Blazor WebAssembly app can be initialized with the `loadBootResource` function
394394
External sources must return the required CORS headers for browsers to allow the cross-origin resource loading. CDNs usually provide the required headers by default.
395395

396396
You only need to specify types for custom behaviors. Types not specified to `loadBootResource` are loaded by the framework per their default loading behaviors.
397+
398+
## Change the filename extension of DLL files
399+
400+
In case you have a need to change the filename extensions of the app's published *.dll* files, follow the guidance in this section.
401+
402+
After publishing the app, use a shell script or DevOps build pipeline to rename *.dll* files to use a different file extension. Target the *.dll* files in the *wwwroot* directory of the app's published output (for example, *{CONTENT ROOT}/bin/Release/netstandard2.1/publish/wwwroot*).
403+
404+
In the following examples, *.dll* files are renamed to use the *.bin* file extension.
405+
406+
On Windows:
407+
408+
```powershell
409+
dir .\_framework\_bin | rename-item -NewName { $_.name -replace ".dll\b",".bin" }
410+
((Get-Content .\_framework\blazor.boot.json -Raw) -replace '.dll"','.bin"') | Set-Content .\_framework\blazor.boot.json
411+
```
412+
413+
On Linux or macOS:
414+
415+
```console
416+
for f in _framework/_bin/*; do mv "$f" "`echo $f | sed -e 's/\.dll\b/.bin/g'`"; done
417+
sed -i 's/\.dll"/.bin"/g' _framework/blazor.boot.json
418+
```
419+
420+
To use a different file extension than *.bin*, replace *.bin* in the preceding commands.
421+
422+
To address the compressed *blazor.boot.json.gz* and *blazor.boot.json.br* files, adopt either of the following approaches:
423+
424+
* Remove the compressed *blazor.boot.json.gz* and *blazor.boot.json.br* files. Compression is disabled with this approach.
425+
* Recompress the updated *blazor.boot.json* file.
426+
427+
The following Windows example uses a PowerShell script placed at the root of the project.
428+
429+
*ChangeDLLExtensions.ps1:*:
430+
431+
```powershell
432+
param([string]$filepath,[string]$tfm)
433+
dir $filepath\bin\Release\$tfm\wwwroot\_framework\_bin | rename-item -NewName { $_.name -replace ".dll\b",".bin" }
434+
((Get-Content $filepath\bin\Release\$tfm\wwwroot\_framework\blazor.boot.json -Raw) -replace '.dll"','.bin"') | Set-Content $filepath\bin\Release\$tfm\wwwroot\_framework\blazor.boot.json
435+
Remove-Item $filepath\bin\Release\$tfm\wwwroot\_framework\blazor.boot.json.gz
436+
```
437+
438+
In the project file, the script is run after publishing the app:
439+
440+
```xml
441+
<Target Name="ChangeDLLFileExtensions" AfterTargets="Publish" Condition="'$(Configuration)'=='Release'">
442+
<Exec Command="powershell.exe -command &quot;&amp; { .\ChangeDLLExtensions.ps1 '$(SolutionDir)' '$(TargetFramework)'}&quot;" />
443+
</Target>
444+
```
445+
446+
To provide feedback, visit [aspnetcore/issues #5477](https://github.com/dotnet/aspnetcore/issues/5477).

0 commit comments

Comments
 (0)