Skip to content

ci: set up vcpkg in PR build workflow#3

Draft
lejcik with Copilot wants to merge 2 commits into
mainfrom
copilot/update-pr-msbuild-workflow
Draft

ci: set up vcpkg in PR build workflow#3
lejcik with Copilot wants to merge 2 commits into
mainfrom
copilot/update-pr-msbuild-workflow

Conversation

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown

GitHub Actions runners have no vcpkg integration, so MSBuild silently skips the vcpkg step and the build fails with missing headers/libs. Locally, vcpkg integrate install runs once and registers global MSBuild .props/.targets, which is why it works on developer machines.

Changes

  • Checkout microsoft/vcpkg into vcpkg/ at workspace root (source stays in s/)
  • Bootstrap vcpkg via bootstrap-vcpkg.bat -disableMetrics
  • Cache vcpkg/installed keyed on runner.os + hashFiles('s/**/vcpkg.json') to avoid rebuilding packages on every run
  • Run vcpkg integrate install so MSBuild picks up vcpkg's .props/.targets and builds manifest dependencies automatically
  • Set VCPKG_ROOT env var on the MSBuild step
- name: Checkout vcpkg
  uses: actions/checkout@v4
  with:
    repository: microsoft/vcpkg
    path: vcpkg

- name: Bootstrap vcpkg
  run: .\vcpkg\bootstrap-vcpkg.bat -disableMetrics
  working-directory: ${{ github.workspace }}

- name: Cache vcpkg installed packages
  uses: actions/cache@v4
  with:
    path: vcpkg/installed
    key: vcpkg-${{ runner.os }}-${{ hashFiles('s/**/vcpkg.json') }}
    restore-keys: |
      vcpkg-${{ runner.os }}-

- name: Integrate vcpkg with MSBuild
  run: .\vcpkg\vcpkg.exe integrate install
  working-directory: ${{ github.workspace }}

- name: Build via MSBuild (Debug | ...)
  env:
    VCPKG_ROOT: ${{ github.workspace }}\vcpkg
  run: ...
Original prompt

Problem

The PR build workflow (.github/workflows/pr-msbuild.yml) does not set up vcpkg before invoking MSBuild. The project uses .vcxproj files with a vcpkg.json manifest for dependencies (e.g. bzip3 and others). On a developer's local machine, vcpkg integrate install has been run once, which registers a global MSBuild .props/.targets file — so it works transparently. On the GitHub Actions runner, none of that integration exists, so vcpkg never bootstraps and the dependent libraries are never built.

The project's .vcxproj files reference $(_ZVcpkgCurrentInstalledDir)include for include paths, which confirms vcpkg integration is expected to be active during the build. Without the integration, MSBuild silently skips the vcpkg step and the build fails with missing headers/libs.

Solution

Update .github/workflows/pr-msbuild.yml to:

  1. Check out the vcpkg repository (microsoft/vcpkg) into a vcpkg/ directory at the workspace root (separate from the source checkout which goes into s/).
  2. Bootstrap vcpkg by running bootstrap-vcpkg.bat -disableMetrics.
  3. Cache the installed packages using actions/cache@v4, keyed on the hash of all vcpkg.json files in the repo, to avoid rebuilding packages from source on every run.
  4. Run vcpkg integrate install so that MSBuild automatically picks up vcpkg's .props/.targets and builds the manifest dependencies before compiling.
  5. Set the VCPKG_ROOT environment variable on the MSBuild step so the toolchain can locate vcpkg if needed.

Implementation Details

  • The vcpkg checkout should be done before the MSBuild build step, after the MSVC dev prompt setup.
  • The working-directory for the bootstrap and integrate steps should be ${{ github.workspace }} (not the s/ subdirectory used as the default for the source).
  • The cache path should be vcpkg/installed and the cache key should incorporate ${{ runner.os }} and ${{ hashFiles('s/**/vcpkg.json') }}.
  • The existing build step (Build via MSBuild) should have VCPKG_ROOT: ${{ github.workspace }}\vcpkg added to its env: block.
  • All other existing steps, options, and structure of the workflow should remain unchanged.

Files to Modify

  • .github/workflows/pr-msbuild.yml

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: it looks like my dependencies were not built, my configuration is .vcxproj project file with vcpkg.json for the dependent libraries, I don't see in the log that vcpkg built the requested libraries (bzip3 and others), while local build on my PC succeeds, any idea what may be wrong?

Assistant: I found the root cause. After reviewing your workflow (pr-msbuild.yml) and your project files, here's what's happening and why:


🔍 Root Cause: vcpkg is Not Set Up in the Workflow

Your workflow does not have a step to bootstrap or integrate vcpkg. The projects rely on vcpkg (they reference $(_ZVcpkgCurrentInstalledDir)include for headers), but the CI runner has no knowledge of where vcpkg is or how to use it.

On your local machine, Visual Studio has a vcpkg integration (vcpkg integrate install) that was run once and registered a global MSBuild .props/.targets file. This is what makes it "just work" locally. The GitHub Actions runner has none of that.


✅ What You Need to Add to the Workflow

You need to add steps to:

  1. Checkout vcpkg (or use the cached version on the runner)
  2. Bootstrap vcpkg
  3. Integrate it with MSBuild so your .vcxproj picks it up automatically
  4. Cache the installed packages to avoid rebuilding every run

Here's the updated workflow with the necessary vcpkg steps:

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          path: s

      - name: Setup MSBuild in PATH (VS2022)
        uses: microsoft/setup-msbuild@v2

      - name: Setup MSVC Developer Command Prompt (x64 toolchain)
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: x64

      # --- ADD THESE STEPS ---

      - name: Checkout vcpkg
        uses: actions/checkout@v4
        with:
          repository: microsoft/vcpkg
          path: vcpkg

      - name: Bootstrap vcpkg
        run: .\vcpkg\bootstrap-vcpkg.bat -disableMetrics
        shell: pwsh
        working-directory: ${{ github.workspace }}

      - name: Cache vcpkg installed packages
        uses: actions/cache@v4
        with:
          path: vcpkg/installed
          key: vcpkg-${{ runner.os }}-${{ hashFiles('s/**/vcpkg.json') }}
          restore-keys: |
            vcpkg-${{ runner.os }}-

      - name: Integrate vcpkg with MSBuild
        run: .\vcpkg\vcpkg.exe integrate install
    ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Co-authored-by: lejcik <34658965+lejcik@users.noreply.github.com>
Copilot AI changed the title [WIP] Update PR workflow to integrate vcpkg before MSBuild ci: set up vcpkg in PR build workflow Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants