In order to authenticate a client against a NuGet repository, NuGet uses an API key for deployment requests. These keys are generated separately on request from a user account on the NuGet gallery and can be regenerated at any time. At regeneration, all previous keys generated for that user are invalid.
For usage with Nexus, NuGet API keys are only needed when packages are going to be deployed; therefore, API key generation is by default not exposed in the user interface to normal users. Only users with the Deployer role have access to the API keys.
Other users that should be able to access and create an API key have to be given the Nexus API-Key Access role in the Users security administration.
In addition, the NuGet API-Key Realm has to be activated. To do this, simply add the realm to the selected realms in the Security Settings section of the Server configuration available in the Administration submenu of the left-hand navigation Nexus panel.
Once this is set up, you can view as well as reset the current Personal API Key in the NuGet tab of any NuGet proxy or hosted repository as visible in Figure 16.7, “Viewing and Resetting the NuGet API Key in the NuGet Configuration Tab”
Creating a package for deployment can be done with the
pack command of
nuget command line tool or within Visual Studio. Detailed
documentation can be found on the NuGet
Manual upload of one or multiple packages is done on the NuPkg Upload tab of the repository displayed in Figure 16.4, “The NuPkg Upload Panel for a Hosted NuGet Repository”. Press the Browse button to access the package you want to upload on the file system and press Add Package. Repeat this process for all packages you want upload, and press Upload Package(s) to complete the upload.
Alternatively to manual uploads, the
nuget command line tool allows
you to deploy packages to a repository with the
push command. The
command requires you to use the API Key and the Package Source
path. Both of them are available in the NuGet tab of the hosted NuGet
repository to where you want to deploy. Using the
nuget allows you to remove packages in a similar fashion.
Further information about the command line tool is available in the on-line help.