Closed majorimi closed 4 years ago
Thanks @majorimi this looks like a bug in our SDK.
Probably. But it is still RC so have time to fix... Thanks.
Please also check is "Scoped CSS merge" works or not? What I mean by that what if a Blazor project uses an internal Component Library (e.g. project reference) with Scoped CSS. And also references some external 3rd party (e.g. Nuget packages) also with Scoped CSS.
In that case will the 2 different CSS merged into one file "_framework/scoped.styles.css"
? Or one will override the other?
@majorimi Can you share a repro project?
@captainsafia Sure here it is.
I'm developing a set of Blazor components and for testing I have 2 TestApps (one WebAssembly
and one Server hosted
). These are referencing the Razor Class Libraries as project ref. So I can test any changes by running the apps locally.
The issue is happening in the demo/Blazor.Components.DemoApp. This app is deployed here to show the usage of my components. And it is intended to use the components from Nuget. But it has a build error with scoped CSS
from Nuget package.
Thanks for your help.
In that case will the 2 different CSS merged into one file
"_framework/scoped.styles.css"
? Or one will override the other?
The two files will be concatenated together (the one from the referenced project and the one from the NuGet package). We have however, changed this in RC2 and the files will be brought in directly via an import
directive relative to the application path bundle.
I'm not able to reproduce the issue with the repro you provided, I've looked at the msbuild binlog and it works as expected. I would suggest you check your environment to ensure you are using the RC1 SDK, clean the bin and obj folders on the projects and perform a clean build.
If your issue still persists, then please try to come up with a minimal repro project that showcases the issue and detailed instructions on how to reproduce it. It's easy for us to do things differently and don't trigger the issue you are seeing.
Thanks for checking it. Have you built the specified branch: dev/update-demo-app-to-nuget
?
I have separated out the non building code to a new branch since it would make CI/CD pipeline fail. master
branch works. I have the DemoApp as well but it is referencing Razor Class Libraries as project ref.
.NET5 RC1
installed...bin
and obj
. Still got the same build error. I also have CI pipeline in Azure Devops which runs on a clean machine. Added a step to install version: '5.0.100-rc.1.20452.10'
. And build fails there too. Very weird issue...
/opt/hostedtoolcache/dotnet/sdk/5.0.100-rc.1.20452.10/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.ScopedCss.targets(97,3): error : The scoped css file '/home/vsts/.nuget/packages/majorsoft.blazor.components.loading/0.9.30-rc.1.20452.10/contentFiles/any/net5.0/LoadingPage.razor.css' was defined but no associated razor component was found for it. [/home/vsts/work/1/s/demo/Blazor.Components.DemoApp/Blazor.Components.DemoApp.csproj]
Ok I will try to create a simpler example or recreate the whole project.
.NET 5 Blazor WebAssembly
project.dotnet add package Majorsoft.Blazor.Components.Loading
Immediately got the same build error. Is it possible that the Nuget package is broken?
Here is the .csproj file:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Majorsoft.Blazor.Components.Loading" Version="0.9.30-rc.1.20452.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-rc.1.20451.17" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-rc.1.20451.17" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0-rc.1.20451.14" />
</ItemGroup>
</Project>
Even added the packaged component to the Index.razor:
@majorimi ah, I think I know what it's happening.
It looks like somehow the file got added as part of the nuget package as content and that's causing the issue.
Hmm I was using the standard .Net Packaging form on the project's properties window. But don't really understand the problem. CSS and JS resources should be packaged anyway. Otherwise how you can distribute these resources in case of your component Nuget packaged?
@majorimi they are scoped css files, so the original css sources are not packaged, only the generated assets.
Ok. Please check my .csproj file: https://github.com/majorimi/blazor-components/blob/master/src/Blazor.Components.Loading/Blazor.Components.Loading.csproj
As I can see it does not specify that CSS should be resource. I don't have .nuspec file specified separately. Just using 'dotnet pack' So probably there's the issue...
@majorimi I believe we fixed something in this area in RC2, so I would suggest you try using a nightly build from here to see if that fixes your issue.
Alternatively, you can likely set pack to false explicitly and that should hopefully do it.
Yes I have got similar answers for other issues to use RC2. However it requires private Nuget feed as well since RC2 packages not published yet... Anyway let's wait for the official RC2 release. It should come in few days.
@majorimi let us know if this works once you have tried things on RC2
Ok will try out with RC2 and let you know. Meanwhile this should be labeled as bug since the default .Net Packaging generates a wrong Nuget package.
Feel free to reopen this if you continue seeing this after upgrading to rc2.
I can confirm that this issue was fixed with .NET5 RC2 update. Thanks.
@mkArtakMSFT I'm facing one more issue related to CSS. The above mentioned isolated CSS was working with WebAssembly projects when Razor Class Library project was referenced directly. But when it is packaged to Nuget and used via Nuget package not directly from project reference. Got this error:
Originally posted by @majorimi in https://github.com/dotnet/aspnetcore/issues/26144#issuecomment-697930110