|
78 | 78 | <Watch Remove="*.scss" /> |
79 | 79 | </ItemGroup> |
80 | 80 |
|
81 | | - <!-- Deletes *.razor.css files that lack a corresponding .razor file in the project before the build process. |
82 | | - This is necessary in Blazor projects with Scoped CSS to prevent build errors caused by orphaned razor.css files, |
83 | | - which may remain after their source razor files are deleted or renamed. For example, if a developer deletes |
84 | | - a razor, razor.cs and razor.scss files and commits the change to Git, another developer who pulls the updated repository will have the |
85 | | - razor, razor.cs and razor.scss file removed from their system, but the generated razor.css file may remain. |
86 | | - This orphaned razor.css file can cause build errors in the ApplyCssScopes task. |
87 | | - The following target ensures such files are deleted before the build, maintaining consistency and preventing errors. --> |
88 | | - <Target Name="DeleteUnmatchedRazorCss" BeforeTargets="ComputeCssScope"> |
| 81 | + <!-- |
| 82 | + Deletes residual *.razor.css* files (such as .razor.css & .razor.css.map) that are missing a corresponding .razor file in the project before build. |
| 83 | + This is necessary in Blazor projects with Scoped CSS to prevent build errors caused by orphaned razor.css files, |
| 84 | + which may remain after their source razor files are deleted or renamed. For example, if a developer deletes |
| 85 | + a razor, razor.cs and razor.scss files and commits the change to Git, another developer who pulls the updated repository will have the |
| 86 | + razor, razor.cs and razor.scss file removed from their system, but the generated razor.css file may remain. |
| 87 | + This orphaned razor.css file can cause build errors in the ApplyCssScopes task. |
| 88 | + The following target ensures such files are deleted before the build, maintaining consistency and preventing errors. |
| 89 | + --> |
| 90 | + <Target Name="DeleteResidualRazorCssFiles" BeforeTargets="ComputeCssScope"> |
89 | 91 | <ItemGroup> |
90 | | - <RazorCssFiles Include="**\*.razor.css" /> |
91 | | - <UnmatchedRazorCssFiles Include="@(RazorCssFiles)" Condition="!Exists('%(RecursiveDir)%(FileName)')" /> |
| 92 | + <RazorCssFiles Include="**\*.razor.css*" /> |
| 93 | + <ResidualRazorCssFiles Include="@(RazorCssFiles)" Condition="!Exists('%(RecursiveDir)%(FileName)')" /> |
92 | 94 | </ItemGroup> |
93 | | - <Delete Files="@(UnmatchedRazorCssFiles)" /> |
| 95 | + <Delete Files="@(ResidualRazorCssFiles)" /> |
94 | 96 | </Target> |
95 | 97 |
|
96 | 98 | </Project> |
0 commit comments