Looking to get the following setup going:
I'm working on a Blazor app, and with the official css isolation bundler. I'm using Less though, and installed a Less transformer which creates the required css on build.
However, running my app via dotnet watch run
, it often ends up in an endless loop now.
The reason for this is probably that dotnet watch run
sees a change in the *.razor.css
files, rebuilds, and the cycle just repeats on and on.
So here's my question:
How can I configure my csproj (new Net Standard format) to exclude **\*.razor.css
from the watch process? It would also be fine it it just disappears from my VS solution as a whole.
Had a play with both answers above, but neither worked for me. I generate some files during the build and that may be why the other 2 don't work for me. According to Microsoft docs shared above (https://learn.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.1), to remove an item from watch you can also set it through the definition. Doing this worked for my scenario.
<ItemGroup>
<Content Remove="wwwroot\dist\**" />
<Content Include="wwwroot\dist\**" Watch="false" />
</ItemGroup>
I did have to add the Content Remove as otherwise the item is declared twice and the build will fail.
Please edit your .csproj file and add the following to it
<ItemGroup>
<Watch Exclude="**\*.razor.css" />
</ItemGroup>
More info at
https://learn.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.1
I had the same issue after coming here, ended up with:
<ItemGroup>
<Watch Remove="wwwroot\**\*" />
</ItemGroup>
Works nicely for me :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With