Error BLAZOR102 when using CSS preprocessing
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Follow up of https://github.com/dotnet/aspnetcore/issues/38374 I’ve successfully managed to use the documentation to copy compiled files to the wwwroot folder using MSBuild.
Now I would like to do the same with Blazor scoped css, but every tutorial I’ve found just places the compiled CSS file inside the git repository instead of the recommended obj/
folder.
I’ve update my repo here https://github.com/JohnKiller/TestCopyFile
Inside RazorClassLibrary1/RazorClassLibrary1.csproj
I’ve placed a fake compilation step that just copies the scss in the obj/
folder and then includes it:
<Target Name="NpmRunBuild" BeforeTargets="AssignTargetPaths" Inputs="Component1.razor.scss" Outputs="$(IntermediateOutputPath)Component1.razor.css">
<Exec Command="copy Component1.razor.scss $(IntermediateOutputPath)Component1.razor.css" />
<ItemGroup>
<Content Include="$(IntermediateOutputPath)Component1.razor.css" Link="Component1.razor.css" />
</ItemGroup>
</Target>
But this is the error I get:
obj\Debug\net6.0\Component1.razor.css : error BLAZOR102: The scoped css file 'obj\Debug\net6.0\Component1.razor.css' was defined but no associated razor component or view was found for it.
To me it looks like since the path is inside obj\Debug
the framework misinterprets the path to be outside the component project location and refuses to bundle it.
Expected Behavior
I would like this solution to work so I can avoid adding the compiled css file to the git repo and keep only the source scss. Using .gitignore
is not an option because it causes the problem described in https://github.com/dotnet/aspnetcore/issues/38374
Steps To Reproduce
Build https://github.com/JohnKiller/TestCopyFile
Exceptions (if any)
obj\Debug\net6.0\Component1.razor.css : error BLAZOR102: The scoped css file 'obj\Debug\net6.0\Component1.razor.css' was defined but no associated razor component or view was found for it.
.NET Version
6.0.101
Anything else?
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top GitHub Comments
error BLAZOR102:
The scoped css file 'obj\Debug\net6.0\Component1.razor.css' was defined but no associated razor component or view was found for it.
Solution:
I recreated the razor component with a different name, copied my code to it, scoped the css file again and copied the css from the former one to it and voila, the error stopped.
Same issue as reported above . To test; I created new Blazor Server solution targeting .net 6. Then created Razor component CustomNotFound.razor and then CustomNotFound.razor.css. VS attaches the css file correctly but then throws error:
Severity Code Description Project File Line Suppression State Error BLAZOR102 The scoped css file ‘Pages\CustomNotFound.razor.css’ was defined but no associated razor component or view was found for it. CustomerService C:\VSApps\Development\CustomerService\CustomerService\Pages\CustomNotFound.razor.css 1