Skip to content

net7: Razor class library - Missing CSS bundle in published package when built using msbuild /maxCpuCount #8175

@hakenr

Description

@hakenr

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Razor class library (Blazor) with CSS isolation.
Published as NuGet package using <GeneratePackageOnBuild>true</GeneratePackageOnBuild>.
Built using "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe" /m.
After upgrade to net7 and VS 17.4.0. the generated .nupkg does not include /staticwebassets/Name.bundle.scp.css. (all other static assets are present).

When the /m switch is removed from the msbuild call, the CSS file is present in the resulting .nupkg.
When the project is multi-targeted to net6+net7, the CSS file is present in the resulting .nupkg.
(Weird behavior observed with /m:1 switch. On our build server, the CSS file is there. On my dev-box, it is not.)

Expected Behavior

The generated .nupkg should contain the CSS bundle no matter which TargetFramework/maxCpuCount is used.

Steps To Reproduce

Unfortunately, I was not successful in reproducing the issue with a minimal project setup.

I prepared a setup (branch) in our repo which reproduces the issue:
https://github.com/havit/Havit.Blazor/tree/net7-msbuild-repro

Call msbuild with /m from project root directory to reproduce the issue:

"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe" /m

Output files (without CSS bundle):
.\Havit.Blazor.Components.Web\bin\Debug\Havit.Blazor.Components.Web.3.2.0.nupkg
.\Havit.Blazor.Components.Web.Bootstrap\bin\Debug\Havit.Blazor.Components.Web.Bootstrap.3.2.0.nupkg

Call msbuild without any switches and the CSS file will be in the output:

"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe"

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

I was not sure in which repository should I file the issue. In the end I decided for aspnetcore as there is a good probability the issue is located in the .target files and/or build-tasks owned by the team?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Work that is important, but not critical for the releasebacklogtriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions