Search code examples
msbuildvisual-studio-2022vcpkg

Problem using vcpkg in Visual Studio (msbuild) with a project built as x86 & x64


I am new to vcpkg and currently facing an issue when building a project that requires to be build as x86 & x64. Maybe I am just missing something or haven't understood how it is intended to work: The issue is that building the project fails for x86 after having it build once for x86 followed by x64.

We have the vcpkg.json and the vcpkg-configuration.json in the project root and use this settings in Visual Studio:

enter image description here

The problem can be reproduced as follows: When first building the project from Visual Studio as Win32, vcpkg builds the x86 dependency libraries. The build succeeds. Now the vcpkg installed directory looks like this:

enter image description here

Building the x64 version afterwards also succeeds but deletes the x86-windows folder in the installed directory. Subsequent builds of the x86 version are then failing (deleting the .msbuildstamp-x86-windows.stamp makes it "work" again as the dependencies are then build again).

enter image description here

I wouldn't have expected this behavior, especially not because the .msbuildstamp-x86-windows.stamp is not deleted.

Thanks for your help.


Solution

  • The problem is caused by the position of the <VcpkgEnableManifest>true</VcpkgEnableManifest> inside the .vcproj file. Although Visual Studio (in our case 2022) shows Use Vcpkg Manifest as Yes in the UI, it is not treated as enabled by vcpkg itself. Moving <VcpkgEnableManifest>true</VcpkgEnableManifest> up inside the .vcproj file solves the issue and correctly enabled manifest mode; see VCPKG issue #27106.