dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.42k stars 10.01k forks source link

Linked files in wwwroot results in "More than one compatible asset found for" error. #48349

Open MorneZaayman opened 1 year ago

MorneZaayman commented 1 year ago

Is there an existing issue for this?

Describe the bug

When linking to files in another project, such as appsettings.json, and then placing these linked files in the Blazor WASM's wwwroot project, a build error occurs with this message: C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.Pack.targets(128,5): error : More than one compatible asset found for.

When moving the linked files out the wwwroot folder, the build completes successfully. Unfortunately, the appsettings.json file must exist in the wwwroot folder. Here is an extract from the .csproj file to make this more clear.

<ItemGroup>
    <Content Include="..\App.UI.Shared\appsettings.Development.json" Link="wwwroot\appsettings.Development.json" />
    <Content Include="..\App.UI.Shared\appsettings.json" Link="wwwroot\appsettings.json" />
    <Content Include="..\App.UI.Shared\appsettings.Test.json" Link="wwwroot\appsettings.Test.json" />
  </ItemGroup>

Expected Behavior

The project builds successfully as if the linked files were actual files in the Blazor WASM project.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

7.0.302

Anything else?

MorneZaayman commented 1 year ago

Repro solution. Issue.zip

How can this be by design? If the appsettings files are directly added to the project the issue does not occur.

mkArtakMSFT commented 1 year ago

Thanks for contacting us. This seems like a bug. For time being we recommend copying the file into your project folder instead of adding it as a linked file.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 11 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

caracostea commented 2 months ago

Any progress on this issue? I'm seeing something similar in .NET 8 Blazor WASM project, when linking an appsettings.Shared.json file in the wwwroot folder:

image