Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete .pch after build on pipeline #3771

Merged
merged 2 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>