Редагувати

Поділитися через


Tutorial: Set up a vcpkg asset cache

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

In this tutorial you'll learn how to:

Prerequisites

  • A terminal
  • vcpkg

1 - Create an asset cache directory

You can use the Azure Blob Storage backend "x-azurl", to store assets. Alternatively, you can use filesystem directories to store your download assets, including network locations. To do so, you need to use the file:// protocol in your asset cache URL.

In this tutorial, you'll create a local asset cache location to store downloaded artifacts. If you have an Azure DevOps Blob Storage you want to use instead, replace the URL and provide a SAS token as the second parameter in the configuration string.

  1. Create a directory to serve as an asset cache location (substitute with any locations of your choosing):
mkdir D:\vcpkg\asset-cache
mkdir /home/vcpkg/asset-cache

2 - Configure X_VCPKG_ASSET_SOURCES

Next set the value of X_VCPKG_ASSET_SOURCES as follows:

$env:X_VCPKG_ASSET_SOURCES="clear;x-azurl,file://D:/vcpkg/asset-cache,,readwrite"

Note

Setting environment variables in this manner only affects the current terminal session. To make these changes permanent across all sessions, set them through the Windows System Environment Variables panel.

set "X_VCPKG_ASSET_SOURCES=clear;x-azurl,file://D:/vcpkg/asset-cache,,readwrite"

Note

Setting environment variables in this manner only affects the current terminal session. To make these changes permanent across all sessions, set them through the Windows System Environment Variables panel.

This X_VCPKG_ASSET_SOURCES configuration adds the following source strings:

  • clear, disables any previously configured asset cache
  • x-azurl,file://C:/vcpkg/asset-cache,,readwrite, sets a filesystem asset cache, located in D:\vcpkg\asset-cache, with read-write permissions.
export X_VCPKG_ASSET_SOURCES="clear;x-azurl,file:///home/vcpkg/asset-cache,,readwrite"

Note

Setting environment variables using the export command only affects the current shell session. To make this change permanent across sessions, add the export command to your shell's profile script (e.g., ~/.bashrc or ~/.zshrc).

This X_VCPKG_ASSET_SOURCES configuration adds the following source strings:

  • clear, disables any previously configured asset cache
  • x-azurl,file:///home/vcpkg/asset-cache,,readwrite, sets a filesystem asset cache, located in home/vcpkg/asset-cache, with read-write permissions.

Next steps

Here are other tasks to try next: