Publish NuGet Packages
Suppose you have a NuGet package and want to publish it to the newly created NuGet feed by:
directly uploading the package to the feed,
using command-line tools like
dotnet
,nuget
orchocolatey
,
Upload NuGet packages
The fastest way to publish a NuGet package is to directly upload it to a NuGet feed.
Open the Packages page and select the required NuGet feed.
Click the Upload button in the top right corner.
Follow the instructions in the window.
Publish NuGet packages using command-line tools
The easiest way to publish a NuGet package to a feed is to run a one-line dotnet nuget push
, nuget push
or choco push
command. The feed's URL and credentials should be provided as command arguments.
To publish NuGet packages using the dotnet tool
Typically, you should specify package name, the feed's URL, and a permanent access token. For example:
dotnet nuget push MyPackage.0.0.1.nupkg -s https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v2/package -k access-token-goes-here
To publish NuGet packages using the nuget tool
Typically, you should specify package name, the feed's URL, and a permanent access token. For example:
nuget push MyPackage.0.0.1.nupkg -Source https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v2/package -ApiKey access-token-goes-here
To publish NuGet packages using the Chocolatey tool
Typically, you should specify the package name, the feed's URL, and a permanent access token. For example:
choco push MyPackage.0.0.1.nupkg -s https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v2/package -k access-token-goes-here
Configure access to a NuGet feed from a local machine
If you don't want to provide credentials or an access token each time you access the feed, you can configure permanent access to the feed. There are several ways to do this:
To configure access to a NuGet feed using the dotnet tool
You should provide feed URL and access credentials using the
dotnet nuget add source
command. For example:dotnet nuget add source https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v3/index.json -n myNuget -u admin -p access-token-goes-here --store-password-in-clear-text
To configure access to a NuGet feed using the nuget tool
You should provide feed URL and access credentials using the
nuget sources add
command. For example:nuget sources add -name foo.bar -source https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v3/index.json -username admin -password access-token-goes-here
To configure access to a NuGet feed using the Chocolatey tool
You should provide the feed URL and access credentials using the
choco source add
command. For example:choco source add -name foo.bar -s https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v3/index.json -u admin -p access-token-goes-here
To configure access to a NuGet feed using NuGet settings
Open the NuGet configuration file. By default, it's located at
Windows:
%appdata%\NuGet\NuGet.Config
macOS/Linux:
~/.config/NuGet/NuGet.Config
or~/.nuget/NuGet/NuGet.Config
In the
packageSources
section, specify the feed's URL.In the
packageSourceCredentials
section, specify credentials of either your own Space account (we recommend that you use a permanent token instead of a password) or a separate service account.The resulting configuration will look similar to the following one:
<configuration> <packageSources> <add key="space" value="https://nuget.pkg.jetbrains.space/mycompany/p/projectkey/mynuget/v3/index.json" protocolVersion="3"/> </packageSources> <packageSourceCredentials> <space> <add key="Username" value="admin"/> <add key="ClearTextPassword" value="access-token-goes-here"/> </space> </packageSourceCredentials> </configuration>
Alternatively, you can use Azure Artifacts Credential Provider. What this tool does is acquire and securely store a token any time you access a NuGet package from the feed.
To configure access to a NuGet feed using Azure Artifacts Credential Provider
Install the tool by downloading and running the helper script: installcredprovider.ps1 (Windows) or installcredprovider.sh (macOs, Linux).
Provide feed credentials. Here you have two options:
Save the credentials in environment variables.
Perform any operation that requires authorization. For example, run
dotnet restore --interactive
in the project directory ornuget restore
. The acquired token will be saved in the session token cache location.
For more information, refer to the tool documentation.
Once you set up the access to the feed, you can publish packages without specifying feed access credentials. For example:
nuget push
ApiKey
key
ApiKey
oco push
ApiKey
k
key
ApiKey
Publish NuGet packages from JetBrains TeamCity
For example, you have a TeamCity build configuration that builds a library and creates a NuGet package. Now, your task is to publish the package to a NuGet feed in Space Packages.
Add the NuGet feed to your build configuration. To do this:
Open build configuration settings.
In Build Features, choose Add build feature.
Choose the Nuget feed credentials feature and specify the feed's URL and service account credentials.
When adding a build step that should work with the feed, for example NuGet Publish, specify the feed's URL. TeamCity will automatically take credentials from the Nuget feed credentials feature.