This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Manifests should install dependencies earlier in build process, before the CustomBuild
target
#20830
Labels
category:vcpkg-feature
The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
info:manifests
This PR or Issue pertains to the Manifests feature
Describe the bug
Manifests should install dependencies before the
CustomBuild
target because their failure to do so means custom build tool items in a project cannot reliably usevcpkg
installed dependencies.This bug/issue is motivated by tools such as
grpc
andprotobuf
, which provide code generation tools to generate.h
,.cpp
.,.py
files and more. A typical way to use them is to add a.proto
file to your project and provide a custom build action that invokesprotoc.exe
or one of thegrpc
tools, generating files that are also part of the project.grpc
andprotobuf
are both ports invcpkg
, sovcpkg
is a natural way to obtain them. Then the custom build action can just point to their tools in thevcpkg
installed directory, e.g.,"$(_ZVcpkgCurrentInstalledDir)tools\protobuf\protoc.exe"
The problem comes when using manifest mode. The targets in
vcpkg.targets
are specified withBeforeTargets=ClCompile
, which means that the manifest dependencies are installed after any files with custom build tools specified are processed. That is, in a clean setup wherevcpkg
has not installed anything, a.proto
file will fail to be processed by theprotobuf
orgrpc
tools that are specified, because those tools do not have a chance to be installed until after the.proto
file is compiledSimply changing
VcpkgInstallManifestDependencies
andVcpkgTripletSelection
invcpkg.targets
to haveBeforeTargets="CustomBuild"
BeforeTargets="CustomBuild;ClCompile"
addresses the issue. Note: I updated from the strikethrough to include bothClCompile
andCustomBuild
, since not specifyingClCompile
breaks the most common usage :-P . But even this isn't great, as it doesn't cover other build actions, e.g.,CudaBuild
as hit by @dahubley in #20884 .Is there any reason to not make this change in
vcpkg.targets
? I'm happy to submit the PR, but I'm not an expert in msbuild and the targets, so I'm not 100% sure that won't have any side effects.Environment
To Reproduce
Steps to reproduce the behavior:
vcpkg
and run.\bootstrap_vcpkg.bat
, and then.\vcpkg.exe integrate install
vcpkg_installed\x86-windows\...
hierarchy next tovcpkg.json
or any mention in the compile output aboutvcpkg
installing dependencies. This is the bug/issue - because custom build tool items don't causevcpkg
dependencies to install, they can't reliably use them.Expected behavior
Install manifest dependencies before any custom build items run
Failure logs
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: