Open Jack-Edwards opened 5 months ago
cc @javiercn
At least I found an workaround. Here goes:
Source folder: C:\Program Files\dotnet\sdk\9.0.100-preview.2.24157.14\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets Target folder: C:\Program Files\dotnet\sdk\9.0.100-preview.3.24204.13\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets
I'm able to build the project I was referring to by using the mcr.microsoft.com/dotnet/sdk:9.0.100-preview.2
Docker image. The 9.0-preview
image is where my issue occurs.
Similarly, GitHub workflows using the step below also fail:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
Another poor work-around is adding an entry to your .csproj:
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
...
<EnableDefaultCompressedItems>false</EnableDefaultCompressedItems>
</PropertyGroup>
<CompressionExcludePatterns>
is another property we could set, but it appears to only respect file extensions patterns, such as **/*.ext
. **/mySpecificFile.ext
doesn't work on my end.
I'm wrong. You can do this to exclude a specific file by name:
<CompressionExcludePatterns>blazorSodium.bundle.js</CompressionExcludePatterns>
However I can't figure out the syntax to exclude multiple, discrete files. Or maybe this only works for files coming from a NuGet package. I have vite setup in my project to compress my own assets down to .gz and .br; doesn't look like I can exclude these assets in the same manner.
Another workaround to avoid static assets compression during build time, add the following in the csproj failing inside PropertyGroup:
<DisableBuildCompression>true</DisableBuildCompression>
Describe the bug
I'm no longer able to build my Blazor WASM project after upgrading the target framework from .NET 8.0 to .NET 9.0 (Preview 3).
Error message included in the "Exceptions" section, below.
I believe this is due to the fact that one of the NuGet packages my project depends on contains pre-compressed static web assets. I.e., the NuGet package already contains
.js.gz
and.js.br
compressed copies of any.js
files. This is a great thing for package maintainers to do to help keep Blazor WASM applications as small as possible.This seems to conflict with a recent modification to the SDK: https://github.com/dotnet/sdk/pull/39213
It seems the dependent project is now responsible for compressing static web assets and
pack
is supposed to exclude them.Are package maintainers supposed to stop distributing pre-compressed static web assets? How should a package maintainer proceed to support multiple framework versions?
I admit my understanding of these events may be wrong. Apologies if that's the case.
Exceptions (if any)
Microsoft.NET.Sdk.StaticWebAssets.targets(488,5): Error : Conflicting assets with the same target path '_content/BlazorSodium/blazorSodium.bundle.js.gz'.