Chapter 10Lesson 03150–205 min

NuGet Repositories, API Keys, Feeds, Symbols, Proxying, and .NET Package Workflows: Configuration, Design Choices, and Tradeoffs

Choose NuGet repository and client controls deliberately: one group versus multiple sources, V3 versus legacy V2, package source mapping, credential storage, deployment policy, API-key lifecycle, symbol retention, public fallback, and current Chocolatey/symbol capabilities.

Package Source MappingCredential hygieneDeployment policyChocolateyTradeoffs

Learning objectives

  • Choose between one Nexus group and multiple NuGet sources based on namespace and policy boundaries.
  • Use Package Source Mapping when multiple client-visible sources are necessary.
  • Compare repository credentials, NuGet API keys, and Pro user-token capabilities without conflating them.
  • Plan deployment policy, symbols, V2/V3 compatibility, Chocolatey, caches, and recovery deliberately.
  • Defend a design using observable package-source and repository behavior.

1. Configuration decisions live in different layers

A NuGet production design spans Nexus repository topology, Nexus authorization, proxy upstreams, client nuget.config, local package caches, CI secret handling, and optionally debugger symbol configuration. Changing one does not automatically change the others. This separation is the foundation for maintainable decisions.

2. One group source: excellent ergonomics, limited visibility into member choice

A single group URL reduces client drift: one source can expose internal hosted packages plus a curated public proxy. Nexus can put hosted members before proxy members and centralize upstream access. This is a strong default when package namespaces are unambiguous.

The tradeoff is that client-side Package Source Mapping sees only the group, not its hidden member repositories. If a public upstream can legitimately publish the same internal package ID, stronger repository-side namespace controls or a separate internal source are needed.

3. Multiple sources plus Package Source Mapping

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="Internal" value="https://repo.example.invalid/repository/nuget-internal/index.json" protocolVersion="3" />
    <add key="Public" value="https://repo.example.invalid/repository/nuget-public/index.json" protocolVersion="3" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="Internal">
      <package pattern="Contoso.*" />
    </packageSource>
    <packageSource key="Public">
      <package pattern="*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

Every direct and transitive dependency must match a mapping pattern. Restore errors during rollout are useful evidence of missing policy coverage. A mapping controls client source eligibility; it does not authenticate the client or change Nexus repository membership.

4. Credential design: convenience versus exposure

Approach Strength Risk / boundary
Environment variable NuGetPackageSourceCredentials_Name No secret written to config; good for ephemeral CI Secret exists in process environment and can be shadowed by stale env values.
Encrypted config credential Usable on Windows under same user/machine Not portable; encryption semantics are platform-bound.
ClearTextPassword in config Portable High leakage risk; avoid for production and never commit.
Credential provider Can integrate with external identity/token flows Provider-specific operational dependency.
Nexus NuGet API key Purpose-built deployment credential Requires NuGet API-Key Realm; rotate/regenerate deliberately.
Nexus User Token Useful non-password credential where licensed Current feature/license prerequisites differ; optional, not mandatory in this Community-first course.

5. Prefer V3, understand V2 rather than pretending it disappeared

Modern NuGet and dotnet workflows should use V3 index.json. Nexus still supports a subset of V2 for compatibility. Older V2-dependent tools and custom OData queries may not be fully compatible with current H2/PostgreSQL-backed Nexus behavior. Do not infer “Nexus supports V2” to mean every deprecated NuGet Gallery query is supported forever.

Chocolatey is a current example of why protocol boundaries matter: Nexus 3.95 added Chocolatey support through NuGet repositories, but mixed V2/V3 group behavior has client-specific constraints. Keep Chocolatey as a separate tested workflow rather than assuming ordinary dotnet restore behavior applies.

6. Release mutability: Disable redeploy is the safer default

A package ID/version should identify one accepted byte sequence. Disable redeploy prevents accidental replacement. Allow redeploy makes the coordinate mutable and can cause clients/caches to disagree about what “1.0.0” means. Read-only is appropriate when publication should stop entirely.

If a build is wrong, publish a new version. Do not rebuild the same version and overwrite it as a normal release process.

7. Symbol retention is a debugging policy

Symbols can be large and may contain source/document references. Decide retention based on incident-debugging requirements, release-support windows, privacy, and storage cost. The package and symbol package should be generated from the same build, but they may have different access and retention expectations.

On Nexus 3.95+, .snupkg plus SymSrv support are current. Older Nexus deployments should not be taught to “repair” a symbol endpoint that did not exist in their version.

8. Three cache layers that operators confuse

Layer Who owns it? What stale state looks like
NuGet global-packages folder Client Restore succeeds without a Nexus request; old package bytes remain locally.
NuGet HTTP cache Client Metadata/resource responses reused locally.
Nexus proxy/metadata cache Nexus Remote package/version changes are not rechecked until freshness rules permit.

Clear or relocate the smallest relevant cache during diagnosis. Do not delete server blobs because a client global-package folder is stale.

9. Worked design: internal libraries plus public OSS

A 60-developer team publishes Acme.* packages, restores hundreds of public packages, runs CI on Linux and Windows, and needs reproducible incident debugging. It cannot tolerate an Acme.* package coming from nuget.org.

Decision Choice Reason/evidence
Read topology Two Nexus groups: internal-only and public-proxy Makes the namespace boundary observable.
Client routing Package Source Mapping Maps Acme.* only to internal; * public to public Nexus group.
Publication Dedicated hosted internal repository Writes never go to group/proxy.
Deployment policy Disable redeploy ID/version remains immutable.
Credentials Environment/secret-store restore credentials; dedicated NuGet API key for publisher Separates read and publish identities.
Symbols Retain .snupkg for supported releases Supports debugging without redefining package identity.
Public egress Only Nexus proxy can reach nuget.org Reduces bypass and provides cache/audit evidence.

10. Community versus optional enterprise capabilities

The mandatory design uses Community-compatible NuGet repositories, API-key realm, local users/roles, file blob storage, and single-node operation. Pro-only SSO, HA, user tokens, cloud storage, staging, and advanced platform integrations are optional architecture extensions. Do not make a developer's ability to restore or publish a lab package depend on those features.

11. Decision checklist

  • Which package IDs are organization-owned?
  • Can public upstreams ever satisfy those IDs?
  • How many client-visible sources are truly necessary?
  • Is V3 explicitly configured with /index.json?
  • Is release redeployment disabled?
  • Where are read credentials and deployment keys stored and rotated?
  • What symbol retention/debugging requirement exists?
  • How will source selection and exact package bytes be proven during an incident?

Knowledge check

When does Package Source Mapping add value?

Why is a single group not enough to prove an internal namespace cannot reach public upstreams?

Why prefer Disable redeploy for releases?

Why can an encrypted NuGet password still be operationally awkward?

Should Chocolatey behavior be inferred from ordinary NuGet restore behavior?

12. Summary

Production NuGet design is a set of explicit boundaries: namespace, source, protocol, write target, credential type, cache, release policy, and symbol retention. Lesson 4 uses those boundaries to diagnose failures without destructive shortcuts.

Official references and version notes

Version-sensitive statements were rechecked on 2026-08-26. The mandatory lab assumes a disposable self-hosted Nexus Repository Community Edition 3.95.2 instance, Java 21 on the Nexus side, and .NET 10 SDK 10.0.400 on the client side. The NuGet symbol/Chocolatey features used here were introduced in Nexus 3.95.0. Record the actual dotnet --info and Nexus version in evidence before execution.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.