Skip to content

Publishing a Razor Class Library (or Class Library) can include extraneous static content #42374

@MarkStega

Description

@MarkStega

Describe the bug:
An RCL (or a plain 'class library') with a wwwroot folder that has a nuget dependency of a library with static assets duplicates the publish of those assets

Version used:
e.g. VS2022 17.3.0 Preview 2

To reproduce:
Steps to reproduce the behavior:

  1. Create a new RCL in a solution
  2. Create a wwwroot folder in that RCL
  3. Use the nuget package manager to add a reference to Material.Blazor
  4. After a short period of time you will observe 6 css/js files get referenced as links in wwwroot of the RCL
  5. Publish your solution (it is sufficient to publish locally to a directory)
  6. Examine the wwwroot _content folder in the published output
  7. Note the the content for Material.Blazor is replicated in your RCL content.
  8. In this particular case there is an added 2.5Mb of content that serves no purpose.
  9. It is very difficult to exclude these static assets as the path for each developer and github action is different since it references the path to the local github repository. This makes DefaultItemExcludes rather worthless. As an example, my references are in the form of
"C:\Users\ms\.nuget\packages\material.blazor\3.0.0-preview.1\contentFiles\any\net6.0\wwwroot\material-components-web.css"

and the next developer could have references like

"C:\Users\sz\.nuget\packages\material.blazor\3.0.0-preview.1\contentFiles\any\net6.0\wwwroot\material-components-web.css"

Expected behavior:
I don't expect that referencing a nuget package with static assets in an RCL will cause those assets to be published.

Actual behavior:
See point 7 above

Edit:

  1. Clarified that the same issue occurs if you include the nuget reference in a class library

Additional context:
Add any other context about the problem here.

.NET SDK (reflecting any global.json):
 Version:   6.0.400-preview.22301.10
 Commit:    25580ffe7a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.400-preview.22301.10\

Host (useful for support):
  Version: 6.0.6
  Commit:  7cca709db2

.NET SDKs installed:
  3.1.420 [C:\Program Files\dotnet\sdk]
  6.0.301 [C:\Program Files\dotnet\sdk]
  6.0.400-preview.22301.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

C:\Users\ms>

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions