lr.Dotnet.NugetConfigTool 2026.4.18.234

lr-nuget-config

NuGet

A command-line tool that creates build/obj/nuget.override.config by merging your repo's nuget.config with user-level NuGet credentials and environment variable URL overrides.

Usage

Run it directly with dnx:

dnx -y lr.Dotnet.NugetConfigTool

Examples

Run in the current directory (walks up to find repo root):

dnx -y lr.Dotnet.NugetConfigTool

Run for a specific repo:

dnx -y lr.Dotnet.NugetConfigTool ~/projects/my-repo

How it works

  1. Repo root discovery — walks up the directory tree to find .git or nuget.config
  2. URL overrides — for each package source in nuget.config, checks for an environment variable derived from the source name:
    • DigitalHubDotnet -> DIGITAL_HUB_DOTNET_NUGET_FEED_URL
    • nuget.org -> NUGET_ORG_NUGET_FEED_URL
    • If the env var is set, the source URL is overridden
  3. Credential merge — reads packageSourceCredentials from ~/.nuget/NuGet/NuGet.Config and merges credentials for matching source names
  4. Writes build/obj/nuget.override.config — used by RestoreConfigFile in Directory.Build.props

When to run

  • After cloning a repo — run once to bootstrap the override config with your credentials
  • In CI pipelines — set URL override env vars, then run before dotnet restore

Env var naming convention

Source key names are split on PascalCase boundaries, dots, hyphens, and underscores, uppercased, and suffixed with _NUGET_FEED_URL:

Source key Env var
DigitalHubDotnet DIGITAL_HUB_DOTNET_NUGET_FEED_URL
nuget.org NUGET_ORG_NUGET_FEED_URL
MyFeed-v2 MY_FEED_V2_NUGET_FEED_URL

Requirements

  • .NET 10.0 or later

Installation

dotnet tool install -g lr.Dotnet.NugetConfigTool

Usage after installation:

lr-nuget-config [directory]

This package has no dependencies.

Version Downloads Last updated
2026.4.18.234 4 04/18/2026
2026.4.18.129 5 04/18/2026