-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BeforeTargets="Build" is not sufficient to include CSS in build output #170
Comments
Hi @mikes-gh , I'm not using Blazor myself, but we do have a Blazor sample app in this repository which does correctly generate scoped css from a scss file with a single build. Do you know if there is any difference between a Blazor app and a Blazor library? Thanks |
@sleeuwen Thanks for the response. The CSS is generated in my scenario as well. I'll work on a repo hopefully with the sample projects in this lib. |
Hi @mikes-gh , I took a look at our BlazorWasmSample and our RazorClassLibrary sample projects, and did a After that, I also took a look at the MudBlazor/MudBlazor repository to see if I could reproduce the issue on there, I compiled the project located at
After these two changes I could run So as far as I can see now it should work correctly, but maybe I'm doing something different than you are doing. |
@sleeuwen thankyou for spending time on this. I spent several days on this and could never get it working. I was using an older version of |
@mikes-gh yes, in the item group for that target is where I added the line from the second diff |
Just to clarify you altered that line to remove |
No, I left the <Target Name="IncludeGeneratedStaticFiles" DependsOnTargets="Compile Sass;Compile JS" BeforeTargets="BeforeBuild">
<Error Condition="!Exists('$(MSBuildProjectDirectory)/wwwroot/MudBlazor.min.css')" Text="Missing MudBlazor.min.css in wwwroot" />
<Error Condition="!Exists('$(MSBuildProjectDirectory)/wwwroot/MudBlazor.min.js')" Text="Missing MudBlazor.min.js in wwwroot" />
<ItemGroup>
<!--Include without duplication-->
+ <_NewCompiledCssFiles Remove="@(_NewCompiledCssFiles)" />
<_NewCompiledCssFiles Include="wwwroot\MudBlazor.min.css" Exclude="@(Content)" />
<_NewCompiledJsFiles Include="wwwroot\MudBlazor.min.js" Exclude="@(Content)" />
<Content Include="@(_NewCompiledCssFiles)" />
<Content Include="@(_NewCompiledJsFiles)" />
</ItemGroup>
</Target> |
OK thats maybe why it works. SInce |
Ahh I didn't notice the BeforeBuild there, I'll see if I can try some more things later this week |
Thanks for your time on this. I'll have a look too. You have stumbled on a good workaround though. I still think |
After spending a few hours on this I am beginning to think this is an incremental build issue. |
Hi @mikes-gh, |
Thanks @sleeuwen. I have deployed the fix to MudBlazor Repo. I'll need to keep an eye on things but so far this looks like a fix. Thanks for all your time on this |
Describe the bug
The current
BeforeTargets="Build;ResolveScopedCssInputs;BundleMinify"
is not sufficient to include the generated assets in a Blazor library.I have to use a copy of the library and use
BeforeTargets="BeforeBuild"
in order for the generated css to be included in published output without building twice.Expected behaviour
Include the generated css in build output even if it doesn't exist (e.g. in a clone publish scenario such as a CI pipeline).
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: