Does NuGet Recover From Expired Feed Credentials During Non-Interactive CI Restores?
0 reputation · 17 Mar 2022, 14:04 UTC
0 reputation · 17 Mar 2022, 14:04 UTC
Private feeds such as Azure Artifacts authenticate through static credentials in NuGet.config or through credential provider plugins such as the Azure Artifacts Credential Provider, which acquires short-lived Microsoft Entra ID tokens. Least-privilege guidance favors narrow scopes: read-only access for restore, package-scoped API keys for push.
The unresolved point is expiry. NuGet does not refresh static NuGet.config credentials, so an expired entry surfaces as 401 Unauthorized during restore and keeps failing until the file is edited. Credential providers can re-acquire tokens, but how reliably that happens in a non-interactive CI run is unclear, and NuGet's per-session credential cache may keep serving stale failures after the credential is renewed. Behavior also differs across dotnet CLI, NuGet.exe, and Visual Studio.
For an unattended restore-only pipeline, the trade-off is a long-lived narrowly scoped credential that will eventually expire versus a provider-based short-lived token whose silent renewal in headless environments still needs verification against current NuGet clients.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.