Aspnetcore: error : The static web asset '[...]\wwwroot\favicon.ico' has a conflicting web root path '/wwwroot/favicon.ico' with the project file 'wwwroot\favicon.ico'.`

Created on 16 Oct 2020  路  11Comments  路  Source: dotnet/aspnetcore

I've updated my project from .NET 5 RC 1 to RC 2 and it doesn't build anymore.

Describe the bug

Building the project throws the following error:
C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(208,5): error : The static web asset 'C:\Users\bruno\source\repos\BrunoBlanes\Average-CRM\Client\wwwroot\favicon.ico' has a conflicting web root path '/wwwroot/favicon.ico' with the project file 'wwwroot\favicon.ico'.

I have tried deleting the favicon.ico file just for the sake of it, but then it throws a new error pointing to the wwwroot\js\jsInterop.js file.

To Reproduce

I'm trying to build a simple Blazor app. It built fine on RC 1. The project is at https://github.com/BrunoBlanes/Average-CRM/tree/development if needed.

Further technical details

  • Include the output of dotnet --info
C:\Users\bruno>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.2.20479.15
 Commit:    da7dfa8840

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.20185
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\

Host (useful for support):
  Version: 5.0.0-rc.2.20475.5
  Commit:  c5a3f49c88

.NET SDKs installed:
  5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]
  5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • Microsoft Visual Studio Community 2019 Preview Version 16.8.0 Preview 4.0
Answered Resolved area-blazor blazor-wasm question

All 11 comments

@BrunoBlanes thanks for contacting us.

This is by design. There are two assets that would end on the same "publish path" in the final project. The recommendation is that you choose which file you want to "win" and remove the other file.

How do I do that? It used to compile without any problems in RC 1.
favicon.ico and jsInterop.js are files that I need for my application.

@BrunoBlanes there are two favicon.ico files, which one of those two do you plan to serve from /favicon.ico? Just remove the other. as per the jsInterop.js i don't see you mentioned that file anywhere in the error, but the process is identical, if you have two files that will end up being served from the same path, you need to either serve one of those files from a different path or remove one of them.

Does that help?

If I understood it correctly, the problem is that I have both favicon.ico and jsInterop.js on Client/wwwroot and Server/wwwroot. I removed it from the client and it now builds fine. I don't understand why this wasn't a problem before RC 2.

Will Blazor WebAssembly be able to retrieve those two files from the server now?

@BrunoBlanes it was a problem before, the server files would always win (silently) over the client ones. There was a bug on the logic that failed to detect this case, and we fixed it on RC2.

I'm not sure why you have those two files on the same path (are you somehow copying) them via MSBuild or something else? (Are they the same files or are they different files?).

If they are different files and you need them both (i'm talking about jsinterop.js) it is likely that you were never loading the one in your client/wwwroot since the one in server/wwwroot would "silently win" so you should decide whether you need both or if the server one is just a copy, then avoid that all together and remove it since client/wwwroot is the original one.

I was actually copying through webpack, I didn't stop to think that they would be at the same address and since I didn't get a warning before I thought it was fine.

Thanks for your help!

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

I have started getting StaticWebAssets related error below for Blazorise Razor Class Library (RCL) packages after updating my Microsoft Visual Studio Professional 2019 Preview to Version 16.8.0 Preview 5.0

`C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(208,5): error : The static web asset 'C:\Users\dimak.nuget\packages\blazorise.bootstrap\0.9.1.2\build..\staticwebassets\blazorise.bootstrap.css' has a conflicting web root path '/wwwroot/_content/Blazorise.Bootstrap/blazorise.bootstrap.css' with the project file 'wwwroot_content\Blazorise.Bootstrap\blazorise.bootstrap.css'.

So confirming the bug (because it is not just a warning, it is an error) needs to be fixed. Really annoying to rollback VS...

P.S. By the way, when we finally get RCL static files be automatically copied to wwwroot/_content folder. It should be an option to do so, instead of publishing ap to some folder and manually copy it. I would suggest adding such feature (could be a package reference attribute, VS UI setting, whatever). This confuses dev community a lot since RCL appeared.

@BrunoBlanes please re-open this issue - this is a bug because this produces ERROR - not WARNING. So it blocks development.

By the way, when we finally get RCL static files be automatically copied to wwwroot/_content folder. It should be an option to do so, instead of publishing ap to some folder and manually copy it. I would suggest adding such feature (could be a package reference attribute, VS UI setting, whatever). This confuses dev community a lot since RCL appeared.

@dmitry-pavlov, sorry no can do, closed by MSFT bot. I suggest pinging @javiercn or opening a new one.

I would consider getting such a bot as well to automatically hide my garbage after the carpet... 馃ぃ

Was this page helpful?
0 / 5 - 0 ratings