File tree Expand file tree Collapse file tree 6 files changed +56
-5
lines changed
Expand file tree Collapse file tree 6 files changed +56
-5
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <Project >
3+ <PropertyGroup >
4+ <EmptyFilesSourcePath >$(MSBuildThisFileDirectory)..\files</EmptyFilesSourcePath >
5+ </PropertyGroup >
6+
7+ <Target Name =" CopyEmptyFilesIncremental"
8+ AfterTargets =" Build"
9+ Condition =" $(DesignTimeBuild) != true"
10+ Inputs =" $(MSBuildThisFileFullPath)"
11+ Outputs =" $(IntermediateOutputPath)EmptyFiles.copied" >
12+
13+ <PropertyGroup >
14+ <EmptyFilesTargetPath >$(TargetDir)EmptyFiles</EmptyFilesTargetPath >
15+ <EmptyFilesMarker >$(IntermediateOutputPath)EmptyFiles.copied</EmptyFilesMarker >
16+ </PropertyGroup >
17+
18+ <ItemGroup >
19+ <EmptyFilesToCopy Include =" $(EmptyFilesSourcePath)\**\*.*" />
20+ </ItemGroup >
21+
22+ <Message Text =" Copying EmptyFiles to $(EmptyFilesTargetPath)" Importance =" high" />
23+
24+ <MakeDir Directories =" $(EmptyFilesTargetPath)" />
25+
26+ <Copy SourceFiles =" @(EmptyFilesToCopy)"
27+ DestinationFiles =" @(EmptyFilesToCopy->'$(EmptyFilesTargetPath)\%(RecursiveDir)%(Filename)%(Extension)')"
28+ SkipUnchangedFiles =" true" />
29+
30+ <Touch Files =" $(EmptyFilesMarker)" AlwaysCreate =" true" />
31+ </Target >
32+ </Project >
Original file line number Diff line number Diff line change 22<Project >
33 <PropertyGroup >
44 <NoWarn >CS1591;CS0649;NU5119;NU1608;NU1109</NoWarn >
5- <Version >8.17.0 </Version >
5+ <Version >8.17.1 </Version >
66 <LangVersion >preview</LangVersion >
77 <AssemblyVersion >1.0.0</AssemblyVersion >
88 <Description >A collection of minimal binary files.</Description >
Original file line number Diff line number Diff line change 11<Solution >
22 <Folder Name =" /Solution Items/" >
33 <File Path =" ../.gitattributes" />
4+ <File Path =" ../buildTransitive/EmptyFiles.targets" />
45 <File Path =" ../readme.md" />
56 <File Path =" .editorconfig" />
67 <File Path =" appveyor.yml" />
Original file line number Diff line number Diff line change 1+ How it works:
2+
3+ 1 . Inputs="$(MSBuildThisFileFile)" - Tracks the package file timestamp
4+ 2 . Outputs="$(EmptyFilesMarker)" - Tracks a marker file in the output directory
5+ 3 . MSBuild automatically skips the target if all outputs are newer than all inputs
6+ 4 . SkipUnchangedFiles="true" - Additional optimization to skip individual unchanged files
7+ 5 . Touch - Updates the marker file timestamp after successful copy
8+
9+ This will only copy files when:
10+
11+ 1 . The targets is newer than the marker file, OR
12+ 2 . The marker file doesn't exist (first build/clean build)
13+
14+ Benefits:
15+
16+ * Dramatically reduces IO on incremental builds
17+ * Works with dotnet clean (removes marker file)
18+ * Still respects individual file changes via SkipUnchangedFiles
Original file line number Diff line number Diff line change 1212 <PackageReference Include =" System.ValueTuple" Condition =" '$(TargetFramework)' == 'net462'" />
1313 <PackageReference Include =" Polyfill" PrivateAssets =" all" />
1414 <PackageReference Include =" Microsoft.Sbom.Targets" PrivateAssets =" all" />
15- <None Include =" .. \EmptyFiles.targets" Pack =" True" PackagePath =" build\EmptyFiles.targets" CopyToOutputDirectory =" PreserveNewest" />
16- <None Include =" .. \EmptyFiles.targets" Pack =" True" PackagePath =" buildTransitive\EmptyFiles.targets" CopyToOutputDirectory =" PreserveNewest" />
17- <None Include =" $(ProjectDir)..\ ..\files\**\empty.*" >
15+ <None Include =" $(SolutionDir)..\buildTransitive \EmptyFiles.targets" Pack =" True" PackagePath =" build\EmptyFiles.targets" CopyToOutputDirectory =" PreserveNewest" />
16+ <None Include =" $(SolutionDir)..\buildTransitive \EmptyFiles.targets" Pack =" True" PackagePath =" buildTransitive\EmptyFiles.targets" CopyToOutputDirectory =" PreserveNewest" />
17+ <None Include =" $(SolutionDir) ..\files\**\empty.*" >
1818 <Pack >true</Pack >
1919 <PackagePath >files</PackagePath >
2020 </None >
Original file line number Diff line number Diff line change 1616 <Using Include =" NUnit.Framework.Legacy.ClassicAssert" Static =" True" />
1717 <Using Include =" NUnit.Framework.Assert" Static =" True" />
1818 </ItemGroup >
19- <Import Project =" $(ProjectDir )..\EmptyFiles.targets" />
19+ <Import Project =" $(SolutionDir )..\buildTransitive \EmptyFiles.targets" />
2020</Project >
You can’t perform that action at this time.
0 commit comments