Skip to content

Instantly share code, notes, and snippets.

@yuriyostapenko
Created October 30, 2018 09:21
Show Gist options
  • Save yuriyostapenko/f988bca133498bbae8381740ec5ab458 to your computer and use it in GitHub Desktop.
Save yuriyostapenko/f988bca133498bbae8381740ec5ab458 to your computer and use it in GitHub Desktop.
Naive file length enforcement before build
<Project>
<Target Name="DubiksCube" BeforeTargets="Build">
<PropertyGroup>
<DubiksLimit>42</DubiksLimit>
</PropertyGroup>
<ItemGroup>
<FilesWithNames Include="@(Compile)" NameLength="$([System.String]::new('%(Identity)').Length)" />
<FilesWithTooLongNames Include="@(FilesWithNames)" Condition="%(NameLength) &gt; $(DubiksLimit)" />
</ItemGroup>
<Error Condition="'@(FilesWithTooLongNames->Count())' &gt; 0" Text="These file names are too long: @(FilesWithTooLongNames)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment