Project vcpkg settings missing from Visual Studio Project Properties

2.3k views Asked by At

One of my vcxproj's (with a vcpkg.json) looks like this existing

And another one (with a vcpkg.json) looks like this. Note the missing option.

enter image description here

But I need to be able to enable the vcpkg Manifest so it can compile! I'm stuck, where did this option go? Both proj's are in the same solution. Both have vcpkg.json added to their Source Files. Notably one has a different dir structure (proj/proj.vcproj vs proj/build/proj.vcproj) so the vcpkg.json is further away

As a design note, conditionally hidden options or grayed-out options are an anti-pattern.

2

There are 2 answers

2
Hajo Kirchhoff On

A vcpkg.json alone is not enough. vcpkg needs to be enabled in your proj.vcproj file.

Try the following steps:

  • Close the solution
  • Open the proj.vcproj files in a normal editor
  • Look for the VcpkgEnableManifest and other vcpkg properties in there. Better still, use WinDiff or a similar DIFF tool to discover the differences between the vcproj files.

I cannot be more specific because you didn't say how you imported/integrated the vcpkg options into your project in the first place. There are many different ways to do that.

For example, I am using the vcpkg export --nuget command to export a nuget package, which I then add to my individual projects with the Visual Studio nuget package manager. This will import "vcpkg.props" from the nuget package directory. This import command adds the options you are missing. If you are using the same method, you probably forgot to add the nuget package to your other project. This way of integrating vcpkg is "per project" rather than globally, so it does not matter if the two projects are in the same solution or not.

If otoh you used the vcpkg integrate command to integrate the vcpkg globally, things will be different. In this case the import command will be inside some Microsoft.props file and the options should appear in all projects.

0
Jonathan On

Okay, I found out how to fix it. I had gotten myself in a corrupted state by unloading and loading VS projects while VS was open AND while running vcpkg integrate project/install commands.

I misunderstood those commands. I thought vcpkg integrate project installed MSBuild vcpkg just for that project so I thought I had to run that for each .vcprojx. Rather, vcpkg integrate project may be better named vcpkg integrate nuget and vcpkg integrate install could be named vcpkg integrate msbuild?

In any case, the fix was to close all instances of Visual Studio (I even uninstalled extra versions), and just run vcpkg integrate install ONCE and then reopen Visual Studio. Then it worked.