Bewerken

Delen via


Tutorial: Set up a vcpkg binary cache using filesystem directories

You are not limited to the default binary cache location as your only local binary cache, it is possible to configure multiple filesystem locations as binary caches. You can even set up specific caches with different permissions, such as read-only, write-only, or read and write permissions.

All binary caches are configured through the VCPKG_BINARY_SOURCES environment variable. The value of VCPKG_BINARY_SOURCES follows a specific configuration syntax.

In this tutorial you'll learn how to:

Prerequisites

  • A terminal
  • vcpkg

1 - Create a binary cache directory

When using the files backend, you can use filesystem directories to store your binary packages, including network locations.

In this tutorial, you'll create two binary cache locations, one with read-write access and a second one with only read access.

Create the two binary cache locations (substitute with any locations of your choosing):

mkdir D:\vcpkg\binary-cache
mkdir \\remote\shared\vcpkg\binary-cache
mkdir /home/vcpkg/binary-cache
mkdir /mnt/remote/shared/vcpkg/binary-cache

2 - Configure VCPKG_BINARY_SOURCES

Next set the value of VCPKG_BINARY_SOURCES as follows:

$env:VCPKG_BINARY_SOURCES="clear;files,\\remote\shared\vcpkg\binary-cache,read;files,D:\vcpkg\binary-cache,readwrite"
set "VCPKG_BINARY_SOURCES=clear;files,\\remote\shared\vcpkg\binary-cache,read;files,D:\vcpkg\binary-cache,readwrite"

This VCPKG_BINARY_SOURCES configuration adds the following source strings:

  • clear, disables any previously configured binary cache, in this case, it disables the default binary cache.
  • files,\\remote\shared\vcpkg\binary-cache,read, sets a binary cache using the filesystem backend, files, located in \\remote\shared\vcpkg\binary-cache, and gives it read-only permissions (read is the default permission).
  • files,D:\vcpkg\binary-cache,readwrite, sets a second filesystem binary cache, located in D:\vcpkg\binary-cache, and gives it read-write permissions (readwrite).
export VCPKG_BINARY_SOURCES="clear;files,/mnt/remote/shared/vcpkg/binary-cache,read;files,/home/vcpkg/binary-cache,readwrite"

This VCPKG_BINARY_SOURCES configuration adds the following source strings:

  • clear, disables any previously configured binary cache, in this case, it disables the default binary cache.
  • files,/mnt/remote/shared/vcpkg/binary-cache,read, sets a binary cache using the filesystem backend, files, located in /mnt/remote/shared/vcpkg/binary-cache, and gives it read-only permissions (read is the default permission).
  • files,/home/vcpkg/binary-cache,readwrite, sets a second filesystem binary cache, located in /home/vcpkg/binary-cache, and gives it read-write permissions (readwrite).

Next steps

Here are other tasks to try next: