microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.27k stars 6.42k forks source link

DLLs managed by vcpkg get removed from output dir when only custom build steps are triggered (MSVC) #23183

Open jjYBdx4IL opened 2 years ago

jjYBdx4IL commented 2 years ago

I'm using https://www.reedbeta.com/blog/custom-toolchain-with-msbuild/ as a template to convert markdown files to rtf and html in my MSVC c++ project.

Everything works fine -- until I make only changes to a markdown file. Then the custom build steps get executed, but the DLLs copied by vcpkg are suddenly gone from the output directory. It looks as if vcpkg sees that a build has been run, decided that the (new) output didn't contain anything needing the DLLs, and then removes them at the end of the build.

Any ideas how to fix that?

Here are the relevant modifications:

.vcxproj:

  ...
  <Import Project="targets.xml" />
</Project>

targets.xml:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)psd.xml" />
    <AvailableItemName Include="markdown1">
      <Targets>MARKDOWN1</Targets>
    </AvailableItemName>
  </ItemGroup>

  <Target
    Name="MARKDOWN1"
    Condition="'@(markdown1)' != ''"
    BeforeTargets="ClCompile">

    <Message Importance="High" Text="Converting markdowns" />

    <!--
    <ItemGroup>
      <ShaderHeader Include="*.hlsli" />
    </ItemGroup>
    <PropertyGroup>
      <ShaderHeaders>@(ShaderHeader)</ShaderHeaders>
    </PropertyGroup>
    -->

    <!-- Setup metadata for custom build tool -->
    <ItemGroup>
      <markdown1>
        <Message>%(Filename)%(Extension)</Message>
        <Command>
          "$(ProgramW6432)\pandoc\pandoc.exe" %(Identity) -o $(OutDir)%(Filename).rtf
          "$(ProgramW6432)\pandoc\pandoc.exe" %(Identity) -o $(OutDir)%(Filename).html
        </Command>
        <!--<AdditionalInputs>$(ShaderHeaders)</AdditionalInputs>-->
        <Outputs>$(OutDir)%(Filename).rtf;$(OutDir)%(Filename).html</Outputs>
      </markdown1>
    </ItemGroup>

    <!-- Compile by forwarding to the Custom Build Tool infrastructure,
         so it will take care of .tlogs and error/warning parsing -->
    <CustomBuild
      Sources="@(markdown1)"
      MinimalRebuildFromTracking="true"
      TrackerLogDirectory="$(TLogLocation)"
      ErrorListRegex="(?'FILENAME'.+):(?'LINE'\d+):(?'COLUMN'\d+): (?'CATEGORY'error|warning): (?'TEXT'.*)" />
  </Target>
</Project>

psd.xml:

<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties">
  <ItemType Name="markdown1" DisplayName="Markdown1" />
  <ContentType Name="markdown1" ItemType="markdown1" DisplayName="Markdown1" />
  <FileExtension Name=".md" ContentType="markdown1" />
</ProjectSchemaDefinitions>
Cheney-W commented 2 years ago

Which port are you installed? Could you please provide your demo repro project to me?

jjYBdx4IL commented 2 years ago

vcpkg integrate install vcpkg install wxwidgets:x64-windows boost-algorithm:x64-windows

https://github.com/jjYBdx4IL/vcpkg-issue-23183-demo

Latest public Visual Studio 2019 release on Windows 11/x64.

Boost isn't needed with this demo, though.

jjYBdx4IL commented 2 years ago

reproduce:

github-actions[bot] commented 5 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

Cheney-W commented 5 months ago

Stay active

kasufert commented 2 weeks ago

Still having this issue