Skip to content

Caching Mechanism ​

msvc-kit uses multiple caching strategies to minimize downloads and speed up operations.

Cache Types ​

CacheLocationPurpose
Download Index<install dir>/downloads/{msvc|sdk}/.../index.dbTrack downloaded files
Manifest Cache<cache root>/manifests/VS manifest with ETag
Extraction Markers<install dir>/.msvc-kit-extracted/Skip re-extraction

Default locations: the installation root is %LOCALAPPDATA%\loonghao\msvc-kit\data on Windows, $XDG_DATA_HOME/msvc-kit on Linux and ~/Library/Application Support/com.loonghao.msvc-kit on macOS; the cache root is %LOCALAPPDATA%\loonghao\msvc-kit\cache on Windows, $XDG_CACHE_HOME/msvc-kit on Linux and ~/Library/Caches/com.loonghao.msvc-kit on macOS.

Download Index ​

The download index is a redb database that tracks:

  • Downloaded file paths
  • File hashes (SHA256)
  • Download timestamps

Skip Logic ​

When downloading, files are skipped based on:

Payload reuse requires the expected source identity. With verification enabled, msvc-kit requires an official SHA256 and rehashes the actual cached file; the index's previous hash is not sufficient. A matching manifest SHA256 takes precedence over inconsistent manifest size metadata. Missing or malformed official digests fail with verification enabled. With verification disabled, file size must match. Downloads use private temporary files and publish only after validation; receipts record actual bytes. Interrupted downloads restart on retry.

Channels always fetch a full current response. Package manifests normally require the SHA256 declared by that fresh channel before parsing or cache publication. On Windows, a mismatching catalog has one alternative authentication path: both the fresh channel and catalog must pass the signed-manifest checks below. Other platforms reject the mismatch. A neighboring metadata file or equal content length cannot establish trust. Download caches and manifests use process locks; a busy index is never renamed as corrupt.

Manifest Cache ​

VS manifests are cached under the configured cache directory: an explicit cache_dir from the TOML file, otherwise <install_dir>/cache/manifests/ when the installation directory is not the platform default (MSVC_KIT_DIR or config --set-dir), otherwise the platform default cache root listed above. Run msvc-kit config to print the cache directory in use.

Authenticated package manifests can use HTTP conditional requests:

GET /manifest.json
If-None-Match: "abc123"
If-Modified-Since: Mon, 01 Jan 2024 00:00:00 GMT

If the manifest hasn't changed, the server returns 304 Not Modified. Before reusing its cached bytes, msvc-kit authenticates them against the fresh channel again; a previous validation result is not sufficient.

Windows signed-manifest fallback ​

When the channel's catalog SHA256 differs from the downloaded bytes, Windows can verify the original SHA256/RSA signatures of both documents. Verification requires a currently valid Windows code-signing certificate chain, an explicit Code Signing EKU, Microsoft publisher CN and organization, and successful revocation checks. Expired, untrusted, revoked, or unavailable revocation information fails closed. The chain must terminate at Microsoft Root Certificate Authority 2011, whose DER SHA256 is pinned to 847df6a78497943f27fc72eb93f9a637320a02b561d0a91b09e87a7807ed7c61; the certificate is published by Microsoft PKI.

The authenticated catalog must also match the fresh signed channel's buildVersion, channel item version, productLine, and productSemanticVersion, with the expected manifestType and manifestName. Cached fallback manifests repeat these signature, current trust, and release-identity checks before a 304 can reuse them. Verification uses native Windows cryptography and requires no external process or additional DLL. Individual package SHA256 verification remains strict and unchanged.

Extraction Markers ​

After extracting a package, a marker file is created:

.msvc-kit-extracted/
├── package1.vsix.done
├── package2.msi.done
└── package3.cab.done

Re-running extraction skips packages with existing markers.

Cache Management ​

View Cache Size ​

powershell
# Download cache
Get-ChildItem "$env:LOCALAPPDATA\loonghao\msvc-kit\data\downloads" -Recurse |
  Measure-Object Length -Sum |
  Select-Object @{N='Size (MB)';E={[math]::Round($_.Sum/1MB, 2)}}

Clear Cache ​

bash
# Clear download cache only
msvc-kit clean --cache

# Clear everything including cache
msvc-kit clean --all --cache

Force Re-download ​

bash
# Clear cache first
msvc-kit clean --cache

# Then download
msvc-kit download

Environment Variables ​

VariableEffect
MSVC_KIT_INNER_PROGRESSSet to 1, true, yes or on to show detailed extraction progress

MSVC_KIT_INNER_PROGRESS is the only cache-related variable the CLI reads. MSVC_KIT_PARALLEL_DOWNLOADS, MSVC_KIT_VERIFY_HASHES, MSVC_KIT_DRY_RUN, MSVC_KIT_MSVC_VERSION, MSVC_KIT_SDK_VERSION, MSVC_KIT_INSTALL_DIR, MSVC_KIT_INCLUDE_COMPONENTS and MSVC_KIT_EXCLUDE_PATTERNS are read by the library's DownloadOptions::default(); the CLI takes these settings from flags and the configuration file instead.

Debugging Cache Issues ​

Enable tracing to see cache decisions:

bash
$env:RUST_LOG = "msvc_kit=debug"
msvc-kit download

Output shows:

DEBUG msvc_kit::downloader: Checking cache for package1.vsix
DEBUG msvc_kit::downloader: Cache hit: package1.vsix (hash match)
DEBUG msvc_kit::downloader: Downloading package2.vsix (not in cache)

Released under the MIT License.