asp.net core - Google Chrome Extension Using C# Blazor: Error "ApplyCompressionNegotiation task failed unexpectedly&

admin2025-05-02  1

Google Chrome Extension Using C# Blazor: Error "ApplyCompressionNegotiation task failed unexpectedly" While Building Blazor BrowserExtension Project in .NET 8.0

Can anyone help me identify what I might be doing wrong or point me to an alternative guide or resource where .NET Core 8.0 or 9.0 is being used?

The "ApplyCompressionNegotiation" task failed unexpectedly.
System.InvalidOperationException: Fingerprint for 't8.0\browserextension\build\BackgroundWorker.js' is not defined.
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.ApplyCompressionNegotiation.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

My setup:

Framework: .NET 8.0 NuGet Package: Blazor.BrowserExtension v2.0.0

BackgroundWorker.js: Included in the wwwroot folder

Steps I've tried: Followed the Quick Start guide. (.BrowserExtension/quick-start)

Cleaned and rebuilt the project using dotnet clean and dotnet build.

Verified that BackgroundWorker.js exists in the wwwroot directory and added the following configuration in the .csproj file:

<ItemGroup>
    <Content Update="wwwroot\BackgroundWorker.js">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemGroup>

Disabled static web assets compression by adding this to the .csproj:

<PropertyGroup>
    <BlazorWebAssemblyEnableCompression>false</BlazorWebAssemblyEnableCompression>
</PropertyGroup>

Google Chrome Extension Using C# Blazor: Error "ApplyCompressionNegotiation task failed unexpectedly" While Building Blazor BrowserExtension Project in .NET 8.0

Can anyone help me identify what I might be doing wrong or point me to an alternative guide or resource where .NET Core 8.0 or 9.0 is being used?

The "ApplyCompressionNegotiation" task failed unexpectedly.
System.InvalidOperationException: Fingerprint for 't8.0\browserextension\build\BackgroundWorker.js' is not defined.
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.ApplyCompressionNegotiation.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

My setup:

Framework: .NET 8.0 NuGet Package: Blazor.BrowserExtension v2.0.0

BackgroundWorker.js: Included in the wwwroot folder

Steps I've tried: Followed the Quick Start guide. (https://mingyaulee.github.io/Blazor.BrowserExtension/quick-start)

Cleaned and rebuilt the project using dotnet clean and dotnet build.

Verified that BackgroundWorker.js exists in the wwwroot directory and added the following configuration in the .csproj file:

<ItemGroup>
    <Content Update="wwwroot\BackgroundWorker.js">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemGroup>

Disabled static web assets compression by adding this to the .csproj:

<PropertyGroup>
    <BlazorWebAssemblyEnableCompression>false</BlazorWebAssemblyEnableCompression>
</PropertyGroup>

Share Improve this question asked Jan 2 at 1:00 ZCoderZCoder 2,3496 gold badges30 silver badges66 bronze badges 1
  • add global.json: { "sdk": { "version": "8.0.307" } } in your project. delete bin and obj folders and run the dotnet build from command prompt. this will help build project without any error. – Jalpa Panchal Commented Jan 2 at 4:03
Add a comment  | 

1 Answer 1

Reset to default 0

You could check the .net sdk version first by running this below command:

dotnet --info

After that add global.json file in your project root folder:

global.json:

{
  "sdk": {
    "version": "8.0.307"
  }
}

Delete bin and obj folders and run the build command from command prompt.

dotnet build

As this is the known issue with the Blazor.BrowserExtension i would like to suggest you submit the feedback on github.

Reference link:

https://github.com/mingyaulee/Blazor.BrowserExtension/issues/184 https://github.com/mingyaulee/Blazor.BrowserExtension/issues/179

转载请注明原文地址:http://www.anycun.com/QandA/1746138128a92101.html