-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Description
Issue
The .Net 9 Blazor WASM compression build task, ApplyCompressionNegotiation
, fails due to an unknown issue handling Razor Class Library Nuget packages that use <StaticWebAssetBasePath>/</StaticWebAssetBasePath>
when referenced by another Razor Class Library
Reproduction Steps
- Create a solution with a .Net 9 Razor Class Library (RCL) and set
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
in its.csproj
. - Publish the RCL as a Nuget package (publishing locally is fine)
- Create a new solution with an .Net 9 Razor Class Library and a .Net 9 Blazor WASM
- In the RCL, add a PackageReference to the Nuget package from step 2 (a ProjectReference does not trigger the bug)
- In the Blazor WASM app add a ProjectReference to the RCL project in the same solution
- Run
dotnet publish --nologo --configuration Release --output bin\Publish
in the Blazor WASM app folder to see the error.
You get an exception similar to:
D:\users\tj\Projects\Issue4\WebWorkers.Issue4\WebWorkers.Issue4>dotnet publish --nologo --configuration Release --output "D:\users\tj\Projects\Issue4\WebWorkers.Issue4\WebWorkers.Issue4\bin\Publish\"
Restore complete (0.5s)
RazorClassLibrary1 net9.0 succeeded (3.3s) → D:\users\tj\Projects\Issue4\WebWorkers.Issue4\RazorClassLibrary1\bin\Release\net9.0\RazorClassLibrary1.dll
RazorClassLibrary1 net9.0 succeeded (0.1s) → D:\users\tj\Projects\Issue4\WebWorkers.Issue4\RazorClassLibrary1\bin\Release\net9.0\RazorClassLibrary1.dll
WebWorkers.Issue4 failed with 1 error(s) and 1 warning(s) (0.6s)
C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(323,5): warning : Endpoints not found for compressed asset: example.JsInterop.faux.js.gz D:\users\tj\Projects\Issue4\WebWorkers.Issue4\WebWorkers.Issue4\obj\Release\net9.0\compressed\87ntuufp02-gq62o8712c.gz
C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(323,5): error MSB4018:
The "ApplyCompressionNegotiation" task failed unexpectedly.
System.InvalidOperationException: Endpoints not found for compressed asset: D:\users\tj\Projects\Issue4\WebWorkers
.Issue4\WebWorkers.Issue4\obj\Release\net9.0\compressed\87ntuufp02-gq62o8712c.gz
at Microsoft.AspNetCore.StaticWebAssets.Tasks.ApplyCompressionNegotiation.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLogging
Context taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
WebWorkers.Issue4 failed (9.7s) → bin\Release\net9.0\wwwroot
Build failed with 1 error(s) and 1 warning(s) in 15.4s
- Workaround: Disable compression (
<CompressionEnabled>false</CompressionEnabled>
) in the 2nd solution's Razor Class Library's.csproj
and the publish will succeed and all static web assets will compress normally.
This issue started as a report about an issue (#4) with SpawnDev.BlazorJS.WebWorkers.
Repo that has projects to demonstrate the issue: WebWorkers.Issue4
Expected behavior
I expected StaticWebAssetBasePath
to work in .Net 9 as it did in .Net 8. This issue did not exist in .Net 8.
Actual behavior
publish
builds fail with the error:
The "ApplyCompressionNegotiation" task failed unexpectedly.
System.InvalidOperationException: Endpoints not found for compressed asset:
Regression?
Unknown
Known Workarounds
Disable compression with <CompressionEnabled>false</CompressionEnabled>
in Razor Class Libraries .csproj
.
Configuration
dotnet --info
.NET SDK:
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.4a280210
MSBuild version: 17.12.7+5b8665660
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\
.NET workloads installed:
[android]
Installation Source: SDK 9.0.100, VS 17.13.35507.96
Manifest Version: 35.0.7/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json
Install Type: Msi
[aspire]
Installation Source: SDK 9.0.100, VS 17.11.35327.3
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: SDK 9.0.100, VS 17.13.35507.96
Manifest Version: 18.1.9163/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.1.9163\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: SDK 9.0.100, VS 17.13.35507.96
Manifest Version: 18.1.9163/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.1.9163\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: SDK 9.0.100, VS 17.13.35507.96
Manifest Version: 9.0.0/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.0\WorkloadManifest.json
Install Type: Msi
[wasm-tools]
Installation Source: SDK 9.0.100
Manifest Version: 9.0.0/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.0\WorkloadManifest.json
Install Type: Msi
[wasm-tools-net8]
Installation Source: SDK 9.0.100
Manifest Version: 9.0.0/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net8\9.0.0\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
.NET SDKs installed:
6.0.102 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.300 [C:\Program Files\dotnet\sdk]
6.0.302 [C:\Program Files\dotnet\sdk]
7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]
7.0.102 [C:\Program Files\dotnet\sdk]
7.0.200 [C:\Program Files\dotnet\sdk]
8.0.101 [C:\Program Files\dotnet\sdk]
8.0.204 [C:\Program Files\dotnet\sdk]
8.0.303 [C:\Program Files\dotnet\sdk]
8.0.401 [C:\Program Files\dotnet\sdk]
8.0.403 [C:\Program Files\dotnet\sdk]
9.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]
9.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Other information
See repo: WebWorkers.Issue4
Activity
LostBeard commentedon Dec 2, 2024
One workaround is to disable compression and the
publish
builds will succeed.In the Blazor WASM project's
.csproj
Another is to use .Net 8 instead of .Net 9 as the issue does not occur in .Net 8.
LostBeard commentedon Dec 3, 2024
Better workaround...
Razor Class Libraries that use Nuget packages affected by this bug can set
<CompressionEnabled>false</CompressionEnabled>
and then the Blazor WASM app can still use compression normally. Maybe the compression stage is being ran twice? Once for the RCL and again for Blazor app?nobba commentedon Dec 5, 2024
The workaround with setting compression to false in the wrapper lib does not work for us, when consuming Webworkers in the wrapper class library and then this wrapper in Blazor application. Setting in the application works but this is obviously not a good solution. Strange that you got it working.
12 remaining items
robertmclaws commentedon Jan 24, 2025
Hey folks, happy new year!
Just wanted to check and see when this was gonna get scheduled to be fixed. Thanks!
srs-adamr commentedon Feb 5, 2025
This seems to occur when using .NET 9 MSBuild with .NET 8 Project, switching my IDE to use the .NET 8 MSBuild, resolved the issue.
LostBeard commentedon Feb 28, 2025
This issue is being reported more and more, but unfortunately it is being reported to package maintainers because users assume it is the Nuget packaged libraries causing the issue and don't realize it is a bug in .Net 9.
Please get this fixed before .Net 10. Skipping an STS version (.Net 9) is acceptable but I am looking forward to .Net 10 (like I was 9) and I would like to actually be able to use it... and so would users of my, and many other's, Nuget packages.
This bug has completely killed the ability to use Net 9 for Blazor WebAssembly because it means you cannot use any Nuget packages that use
<StaticWebAssetBasePath>
without causing the publish build to fail.That makes this a CRITICAL BUG.
marqdouj commentedon Mar 13, 2025
fwiw,
I just installed VS2022 Version 17.14.0 Preview 2.0 and now I get this error in a rcl that compiled no problem in any other previous version.
Adding this does make the error go away.
<PropertyGroup> <CompressionEnabled>false</CompressionEnabled> </PropertyGroup>
The package that caused the error was AzureMapsControl
lofcz commentedon Apr 3, 2025
There are two open PRs solving this, untriaged for over two months.. seconding this NEEDS to be fixed before .NET 10, we skipped 9 due to this too.
BenWhite27 commentedon Apr 4, 2025
This just bit me as well. Wasted a good part of the week because this error was happening during a cloud deploy but the actual error message was hidden for me.
This should be expanded to not just be area-blazor as well. This seems to affect any project with a RCL library referenced as above.
For me it was an Umbraco site in Umbraco Cloud.
robertmclaws commentedon Apr 13, 2025
I'm amazed, yet not, that this issue is still open.
Workaround for dotnet/aspnetcore#59291
Workaround for dotnet/aspnetcore#59291
LostBeard commentedon Jun 5, 2025
I had this issue appear again during a .Net 8 Blazor WASM app publish even though I was using
<CompressionEnabled>false</CompressionEnabled>
. As usual, this issue only appeared during publish, and not during builds.Solution layout
A .Net 8 "Blazor WebAssembly Standalone App" and a .Net 8 "Razor Class Library". Both projects referenced the same project which uses the
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
, SpawnDev.BlazorJS, but the RCL referenced a slightly older version.Fix
Updating the reference in the RCL project to match the one in the Blazor WASM app project fixed the issue.
Just mentioning this here in case anyone else gets this error with .Net 8 app and using
<CompressionEnabled>false</CompressionEnabled>
flag. Check your referenced lib versions match as a possible fix (workaround.)