This is quick guide to manage your NuGet package in your private server. Before going into steps with publishing a NuGet package you need to have prepared assembly. Also you should download NuGet.exe CLI from nuget.org/downloads
Steps
Command | Description | Comment |
nuget.exe spec | Create *.nuspec file to describe the package | The command should be executed in the folder with the project file. The *.nuspec template will be created automatically. Mandatory fields are ID and Description. Values with $param$ will be added from the assembly. You can use literals in the version value to define pre-release version. |
nuget.exe pack YourPackage.csproj | Create a package | It will create the package using build configuration of your project. Example output file: YourPackage.1.0.0-alfa.nupkg |
nuget.exe push YourPackage.1.0.0-alfa.nupkg KEY -Source PRIVATE_SERVER | Publish your package | |
nuget.exe delete YourPackage 1.0.0-alfa -Source PRIVATE_SERVER -ApiKey KEY | Delete your package from the server | |
When the package is published you can find it in the Package Manager Console of Visual Studio. If the package was published as pre-released version you should user -IncludePrerelease parameter: Find-Package YourPackage -AllVersions -IncludePrerelease
Securing the Key
In order to avoid using the key inside of your deployment scripts you should call nuget SetApiKey KEY. This command will save the key encrypted in a config file under your %APPDATA% folder. For example: C:\Users\USER\AppData\Roaming\NuGet\NuGet.Config. The key is saved per each NuGet server URL.