dockervisual-studiovcpkg

Building with VsBuildTools, using vcpkg in Docker


I am trying to set up a Windows Server-based CI to compile a VS project whose dependencies are managed by vcpkg; my container manager is Docker. I am using Window Server as a base (mcr.microsoft.com/windows/servercore:10.0.17763.5576).

I generated the container using VS Build Tool 2022, installing the compiler and adding vckpg as well; however, I am facing many difficulties preparing the container because of vcpkg.

When I try to compile the project in the host OS, everything works fine, and dependencies are correctly downloaded and linked. Conversely, when I run the vcpkg install command in the cloned repository inside the container, I get the error: "Could not locate a complete Visual Studio instance". After the message, nothing is written, so vcpkg is not giving the list of environments it scanned.

I tried all sorts of fixes:

  1. I tried adding the workloads suggested here,
  2. I tried installing VS 2019 Community (with no success, the installer will silently refuse to install),
  3. I defined environment variables VCPKG_VISUAL_STUDIO_PATH, VCPKG_ROOT to point, respectively, to the root folder of VS 2022 and vcpkg,
  4. I tried the solution suggested here, with no luck.

Up to this point, I was unable to install the required dependencies.

Has someone solved this problem?


Solution

  • The solution to this problem is described here and amounts at installing many optional packages.

    Here is the command I employed to install the tools in the container.

    vs_BuildTools install ; \
        --includeRecommended --includeOptional ; \
        --add Microsoft.VisualStudio.Workload.VCTools ; \
        --add Microsoft.VisualStudio.Component.VC.ATLMFC ; \
        --add Microsoft.VisualStudio.Workload.VisualStudioExtensionBuildTools ; \
        --quiet --norestart --nocache --wait
    

    While this will make another Visual Studio instance available, it is basically Visual Studio 14.0.

    After that the container must be update to actually employ the 2022 version.