If you are managing a .NET solution where documentation files reside in a root-level docs folder, you might run into issues where MSBuild or static web assets unnecessarily scan, compile, or include these files in your build output.
You can easily prevent this by adding a targeted MSBuild configuration to your project file (.csproj).
The MSBuild Snippet
Add the following <ItemGroup> snippet directly into your project's .csproj file:
<ItemGroup>
<!-- Prevent static web assets and MSBuild from scanning the docs folder -->
<Content Remove="..\..\docs\**" />
<None Include="..\..\docs\**" />
</ItemGroup>
Why Use This?
Content Remove: Stops MSBuild from treating the files inside the parentdocsdirectory as web content or publishable assets.None Include: Ensures that while the files are ignored by build pipelines and static asset scanners, they still remain visible within your solution explorer (depending on your IDE settings) without triggering build actions.Path Traversal (
..\..\): Adjust the number of..\segments depending on how deep your.csprojfile is nested relative to the rootdocsfolder
No comments:
Post a Comment