How NuGet caching works
NuGet V3 feeds start from a service index that points to the resources a client needs: package metadata, the flat container with .nupkg files, and search. Cacheport implements the restore-related resources and caches packages permanently.
Packages are served unmodified, so the content hashes in packages.lock.json keep matching and signed packages keep their signatures.
- Registration metadata
- Refreshed every 5 minutes.
- .nupkg files
- Cached forever, signatures intact.
- Search
- Passed through to the upstream.
Set it up
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="cacheport" value="https://acme.cacheport.cc/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<cacheport>
<add key="Username" value="ci" />
<add key="ClearTextPassword" value="%CACHEPORT_TOKEN%" />
</cacheport>
</packageSourceCredentials>
</configuration>NuGet expands %CACHEPORT_TOKEN% from the environment on every platform. The <clear /> element removes nuget.org so nothing goes around the cache.
Use it in CI
Store the token as a secret named CACHEPORT_TOKEN, then pick your provider.
GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
env:
CACHEPORT_TOKEN: ${{ secrets.CACHEPORT_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- run: dotnet restore --locked-mode
- run: dotnet test --no-restoreMore for GitHub Actions: GitHub Actions setup guide.
GitLab CI
build:
image: mcr.microsoft.com/dotnet/sdk:8.0
script:
- dotnet restore --locked-mode
- dotnet test --no-restoreMore for GitLab CI: GitLab CI setup guide.
Package source mapping
If you use several feeds, NuGet's package source mapping decides which feed serves which package IDs. With Cacheport you can keep mapping simple: add private feeds as upstreams of the workspace and map everything to the single Cacheport source.
Troubleshooting
Errors that usually mean the public registry is the bottleneck, and what Cacheport changes about them.