Skip to content

Build Error when using TimeWarp.State in multiple Razor Class-Libraries #529

@sgubler-weroSoft

Description

@sgubler-weroSoft

I have a Blazor-WASM Applikation that has TargetFramework=net8.0 with Razor Class-Libraries that are referenced from the client-project by project references. I use the Library TimeWarp.State. My problem is that I get a build error on the client-project if more than one Razor Class-Library references TimeWarp.State. The error is as follows:

Severity Code Description Project File Line Suppression State Details
Error (active) MSB4018 The "DiscoverPrecompressedAssets" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverPrecompressedAssets.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() BlazorWASMWithTimeWarp.State.Client C:\Program Files\dotnet\sdk\9.0.300\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets 289

The problem seems to be that each Razor Class Library Project that references TimeWarp.State contains a folder "types" in wwwroot that contains linked files fe. one is called "Constants.d.ts". I assume that the "DiscoverPrecompressedAssets" task tries to add a file from one Razor Class Library that was already added from the other Razor Class Library.

How can I solve this issue? Should I move all states into a single projects that is referenced from the other projects?

Here is an example demonstrating the problem:
TimeWarp.State-Issue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions