Edit

Share via


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

vcpkg offers the following asset cache providers:

  • x-azurl: which is intended to work with Azure Blob Storage containers, but works just as well with other service providers and even local or network filesystems.
  • x-script: which lets you add your own business logic to handle asset caching through a customizable script or executable.

This tutorial uses, x-azurl as the provider to store assets in a local directory in your filesystem using a URL with the file:// protocol.

Note

You can use these same steps to create an asset cache with Azure Blob Storage. Replace any URL in the tutorial with the URL for your storage and provide a SAS Token for authentication.

  1. Create a directory to serve as an asset cache location (substitute with any locations of your choosing):
mkdir Z:\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:///Z:/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:///Z:/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:///Z:/vcpkg/asset-cache,,readwrite, sets a filesystem asset cache, located in Z:\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: