Skip to content

Commit 10a3599

Browse files
committed
improve msbuild task to remove residual .razor.css.map files
1 parent eb90698 commit 10a3599

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Build.props

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,21 @@
7878
<Watch Remove="*.scss" />
7979
</ItemGroup>
8080

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">
8991
<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)')" />
9294
</ItemGroup>
93-
<Delete Files="@(UnmatchedRazorCssFiles)" />
95+
<Delete Files="@(ResidualRazorCssFiles)" />
9496
</Target>
9597

9698
</Project>

0 commit comments

Comments
 (0)