Skip to content

Commit

Permalink
Delete .pch after build on pipeline (#3771)
Browse files Browse the repository at this point in the history
* delete pch after build
  • Loading branch information
licanhua authored Dec 13, 2019
1 parent c09b55c commit 54bc2b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "none",
"comment": "Delete .PCH ",
"packageName": "react-native-windows",
"email": "licanhua@live.com",
"commit": "42a383343b2b7624fb05efd5253064d9102746de",
"date": "2019-12-13T19:33:23.242Z"
}
22 changes: 22 additions & 0 deletions vnext/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,26 @@
<Message Text="=> VCTargetsPath [$(VCTargetsPath)]" />
</Target>

<Target Name="_ComputePrecompToCleanUp">
<ItemGroup>
<PCHFileToClean Include="$(IntDir)\**\*.pch" />
<_PCHFileToCleanWithTimestamp Include="@(PCHFileToClean)" Condition="'%(Identity)' != ''">
<LastWriteTime>$([System.IO.File]::GetLastWriteTime('%(Identity)'))</LastWriteTime>
</_PCHFileToCleanWithTimestamp>
</ItemGroup>
</Target>
<!--
As a cppwinrt project, .pch is very big, and delete it in pipeline after build
Instead of outright deleting the PCHs, we want to trick the "project freshness detector" by
emitting empty files that look suspiciously like the PCHs it's expecting.
It's of utmost importance that their timestamps match up. -->
<Target Name="CleanUpPrecompHeaders"
DependsOnTargets="_ComputePrecompToCleanUp"
AfterTargets="AfterBuild"
Condition="'$(AGENT_ID)' != ''">
<!-- We just need to keep *ReactNativeWindows*'s PCHs because they get rebuilt more often. -->
<Delete Files="@(_PCHFileToCleanWithTimestamp)"/>
<Touch Files="@(_PCHFileToCleanWithTimestamp)" Time="%(LastWriteTime)" AlwaysCreate="true" />
<Message Text="PCH and Precomp object @(_PCHFileToCleanWithTimestamp) has been deleted for $(ProjectName)." />
</Target>
</Project>

0 comments on commit 54bc2b7

Please sign in to comment.