Nuget_credentialproviders_path [exclusive]
The environment variable NUGET_CREDENTIALPROVIDERS_PATH is a powerful configuration tool used to tell nuget.exe exactly where to look for custom credential providers. While modern NuGet versions often use the "plugin" model via NUGET_PLUGIN_PATHS , this specific variable remains essential for legacy V2-style providers and certain specialized build environments. What is NUGET_CREDENTIALPROVIDERS_PATH? By default, nuget.exe searches for credential providers in specific standard locations, such as the same folder as the executable or %LocalAppData%\NuGet\CredentialProviders . The NUGET_CREDENTIALPROVIDERS_PATH variable overrides or extends these locations, allowing you to store and access providers from any directory. Format: A semicolon-separated list of paths (e.g., C:\Tools\Auth;D:\Build\Plugins ). Discovery Logic: NuGet scans these directories for any file named credentialprovider*.exe and loads them in alphabetical order. When to Use This Variable Using this variable is particularly useful in scenarios where a standardized environment is required without modifying the user's local profile: CI/CD Pipelines: In environments like Azure Pipelines or Jenkins, you can point NuGet to a specific directory containing the Azure Artifacts Credential Provider without installing it globally. Portable Build Environments: If you share a "tools" folder across a team, setting this variable ensures every machine uses the same authentication logic without individual setup. Legacy Support: It is the primary way to manage "old-style" providers that don't support the cross-platform plugin model. Implementation Guide To set up a custom path, use the command line or system environment settings: Windows (Command Prompt): set NUGET_CREDENTIALPROVIDERS_PATH=C:\Custom\NuGet\Providers Use code with caution. Windows (PowerShell): powershell $env:NUGET_CREDENTIALPROVIDERS_PATH = "C:\Custom\NuGet\Providers" Use code with caution. Troubleshooting Common Issues If your credential provider isn't loading from the path you've set, check the following: Naming Convention: Ensure the executable file follows the credentialprovider*.exe pattern. Verbosity: Run NuGet with -verbosity detailed to see exactly where it is searching for providers. NuGet Version: This feature requires nuget.exe version 3.3 or higher. Permissions: The account running the command must have read and execute permissions for the folder specified in the path. NUGET_CREDENTIALPROVIDERS_PATH vs. NUGET_PLUGIN_PATHS While NUGET_CREDENTIALPROVIDERS_PATH is specifically for credential providers, NUGET_PLUGIN_PATHS is used for the newer, more versatile plugin system introduced in NuGet 4.8+. If you are using the latest version of the Azure Artifacts Credential Provider, it is often recommended to use the plugin model for better performance and cross-platform support. Are you setting this up for a local development machine or a CI/CD build agent ? nuget.exe Credential Providers - Microsoft Learn
The environment variable NUGET_CREDENTIALPROVIDERS_PATH is a critical configuration setting used by NuGet to locate cross-platform credential providers . It allows NuGet to authenticate with private package feeds (like Azure Artifacts or GitHub Packages) by pointing to the executable files that handle the login handshake. Core Functionality When NuGet needs to access a protected feed, it searches the directories defined in this variable for plugin files. Discovery : NuGet looks for executable files that follow the naming convention CredentialProvider.* (e.g., CredentialProvider.Microsoft.exe on Windows or CredentialProvider.Microsoft on Linux/macOS). Priority : This environment variable takes precedence over the default installation folders. If it is set, NuGet will prioritize these paths when looking for plugins. Common Use Cases Azure Artifacts : The Azure Artifacts Credential Provider is the most common reason to use this variable. It enables interactive or automated (device flow) authentication for Azure DevOps feeds. CI/CD Pipelines : In automated environments like GitHub Actions or Azure Pipelines, you often set this path to a folder where you have pre-downloaded the credential provider to ensure the build agent can authenticate without manual intervention. Custom Locations : If you want to share a single credential provider across multiple versions of the .NET SDK or IDEs (Visual Studio, Rider) without reinstalling it for each, you can store it in a central folder and point this variable to it. How to Set It You can define multiple paths by separating them with a semicolon (Windows) or a colon (Linux/macOS). Windows (PowerShell) : powershell $env:NUGET_CREDENTIALPROVIDERS_PATH = "C:\Users\Name\.nuget\plugins\netcore\CredentialProvider.Microsoft" Use code with caution. Copied to clipboard Linux/macOS (Bash) : export NUGET_CREDENTIALPROVIDERS_PATH="$HOME/.nuget/plugins/netcore/CredentialProvider.Microsoft" Use code with caution. Copied to clipboard Important Considerations Plugin Architecture : Modern NuGet uses a "plug-in" model. The credential provider must be compatible with the version of NuGet/dotnet you are using (e.g., .NET Core-based plugins for dotnet restore ). Troubleshooting : If you are still being prompted for credentials despite setting the path, you can run your command with increased verbosity ( dotnet restore -v n ) to see where NuGet is looking for plugins. Are you trying to set this up for a specific CI/CD provider or a local development environment?
What is nuget_credentialproviders_path ? It is an environment variable that tells NuGet (and the .NET SDK) where to look for external credential providers — executable programs that supply authentication credentials for private NuGet feeds (e.g., Azure Artifacts, GitHub Packages, MyGet, or on-premises servers like Artifactory or Nexus). When do you need it?
You are using a private feed that requires interactive or non-interactive authentication (e.g., Azure DevOps, GitHub Packages with PAT, or a custom provider). The built-in authentication methods (basic auth, NuGet.config API keys) are insufficient. You want to share a single credential provider binary across multiple machines or build agents. nuget_credentialproviders_path
How to use it (step by step) 1. Obtain a credential provider Common examples:
Azure Artifacts Credential Provider (for Azure DevOps) GitHub Packages Credential Provider (or just use a PAT in NuGet.config) Custom provider (any executable named NuGetCredentialProvider.exe on Windows or NuGetCredentialProvider on Linux/macOS)
2. Place the provider in a directory Example folder structure: C:\NuGet\CredentialProviders\MyProvider.exe By default, nuget
Or on Linux: /opt/nuget/credentialproviders/MyProvider
3. Set the environment variable Windows (Command Prompt) set NUGET_CREDENTIALPROVIDERS_PATH=C:\NuGet\CredentialProviders
Windows (PowerShell) $env:NUGET_CREDENTIALPROVIDERS_PATH="C:\NuGet\CredentialProviders" Discovery Logic: NuGet scans these directories for any
Linux/macOS (bash) export NUGET_CREDENTIALPROVIDERS_PATH=/opt/nuget/credentialproviders
Permanent (Windows)
