Fix IncrementalClean deleting vcpkg-deployed DLLs on incremental builds (#50521)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ben Foxworthy 2026-03-18 16:52:09 -07:00 committed by GitHub
parent 5111afdf55
commit c3867e714d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -256,4 +256,27 @@
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
</ItemGroup>
</Target>
<!--
When the link step is skipped (incremental build, exe up-to-date),
AppLocalFromInstalled doesn't run, so DLLs it previously copied aren't
registered in FileWrites. MSBuild's IncrementalClean then treats them as
orphan outputs and deletes them. This target re-registers those DLLs so
IncrementalClean leaves them alone.
-->
<Target Name="AppLocalFromInstalledPreserve"
AfterTargets="CopyFilesToOutputDirectory"
BeforeTargets="_CleanGetCurrentAndPriorFileWrites"
Condition="'$(_ZVcpkgClassicOrManifest)' == 'true'
and '$(VcpkgApplocalDeps)' == 'true'
and '$(LinkSkippedExecution)' == 'true'
and '@(Link)' != ''">
<ReadLinesFromFile File="$(IntDir)vcpkg.applocal.log"
Condition="Exists('$(IntDir)vcpkg.applocal.log')">
<Output TaskParameter="Lines" ItemName="_ZVcpkgPreservedAppLocalDLLs" />
</ReadLinesFromFile>
<ItemGroup>
<FileWrites Include="@(_ZVcpkgPreservedAppLocalDLLs -> '$(OutDir)%(Filename)%(Extension)')" />
</ItemGroup>
</Target>
</Project>