Skip to content

Commit c3867e7

Browse files
benfoxworthyclaude
andauthored
Fix IncrementalClean deleting vcpkg-deployed DLLs on incremental builds (#50521)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5111afd commit c3867e7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

scripts/buildsystems/msbuild/vcpkg.targets

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,27 @@
256256
<ReferenceCopyLocalPaths Include="@(VcpkgAppLocalDLLs)" />
257257
</ItemGroup>
258258
</Target>
259+
260+
<!--
261+
When the link step is skipped (incremental build, exe up-to-date),
262+
AppLocalFromInstalled doesn't run, so DLLs it previously copied aren't
263+
registered in FileWrites. MSBuild's IncrementalClean then treats them as
264+
orphan outputs and deletes them. This target re-registers those DLLs so
265+
IncrementalClean leaves them alone.
266+
-->
267+
<Target Name="AppLocalFromInstalledPreserve"
268+
AfterTargets="CopyFilesToOutputDirectory"
269+
BeforeTargets="_CleanGetCurrentAndPriorFileWrites"
270+
Condition="'$(_ZVcpkgClassicOrManifest)' == 'true'
271+
and '$(VcpkgApplocalDeps)' == 'true'
272+
and '$(LinkSkippedExecution)' == 'true'
273+
and '@(Link)' != ''">
274+
<ReadLinesFromFile File="$(IntDir)vcpkg.applocal.log"
275+
Condition="Exists('$(IntDir)vcpkg.applocal.log')">
276+
<Output TaskParameter="Lines" ItemName="_ZVcpkgPreservedAppLocalDLLs" />
277+
</ReadLinesFromFile>
278+
<ItemGroup>
279+
<FileWrites Include="@(_ZVcpkgPreservedAppLocalDLLs -> '$(OutDir)%(Filename)%(Extension)')" />
280+
</ItemGroup>
281+
</Target>
259282
</Project>

0 commit comments

Comments
 (0)