- 1 year ago
How can I use nuget.exe to download protected (private) nuget package from artifactory
To download a protected (private) NuGet package from Artifactory using nuget.exe
, you need to configure authentication and provide the necessary credentials. Here are the steps to do so:
Obtain Artifactory API Key: In Artifactory, generate an API Key or an Access Token that has the necessary permissions to access the private NuGet package. This key or token will be used for authentication.
Configure
nuget.config
: Create or modify thenuget.config
file in the directory wherenuget.exe
is located. Add or update the<packageSources>
section to include your Artifactory repository as a package source. Specify the repository URL and a name for the source. For example:xml<packageSources>
<add key="MyArtifactory" value="https://artifactory.example.com/api/nuget/my-repo" />
</packageSources>
Authenticate with Artifactory: Open a command prompt or terminal and run the following command to authenticate with Artifactory using the API Key or Access Token:
phpnuget sources update -Name MyArtifactory -UserName <APIKey> -Password <APIKeyValue>
Replace
<APIKey>
with your Artifactory API Key or Access Token, and<APIKeyValue>
with the actual value of the key.Download the NuGet Package: Run the
nuget install
command to download the NuGet package from Artifactory. Specify the package name and any additional options as needed. For example:nuget install MyPackage -Source MyArtifactory
Replace
MyPackage
with the actual name of the NuGet package.
With these steps, nuget.exe
will authenticate with Artifactory using the provided API Key or Access Token and download the protected NuGet package from the specified repository.
Note: Make sure you have the correct permissions and access rights to the protected NuGet package in Artifactory.