Setup a private nuget server

Deploy nuget server project

Nuget Server package on

The project source:

deploy the project to IIS, and configure the web.config

1. set the apiKey for pushing packages to the server
2. set packagesPath to store all the packages, the default will be ~/Packages (you need to give write permissions for the app pool user)

Pushing packages

1. using nuget CLI

nuget.exe push -Source {NuGet package source URL} -ApiKey key {your_package}.nupkg

2. using dotnet core CLI

dotnet pack --configuration release
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s http://customsource/

Enable authentication for accessing nuget server

1. enable windows authentication on the server site on IIS
2. create a windows user
3. adding the repository source with username and password (using nuget CLI), it will be saved into the global nuget.config file. (normally in Nuget has a global nuget.config, saved in \Users\%AppUSer%\AppData\Roaming\NuGet)
nuget.exe sources add -name {feed name} -source {feed URL} -username {username} -password {PAT} -StorePasswordInClearText

If you don’t have the username & password, it will return a 401 unauthorized error. In visual studio, it will prompt a dialog asking for credentials.

Restore nuget packages using nuget config per solution

If you work on a new machine, and checkout source code of a project, you will need to configure the nuget source, username, password etc. To enable developers restore the packages and build the project without any hassles, we can create a nuget.config per solution.

<?xml version="1.0" encoding="utf-8"?>
<add key="Username" value="spnugetuser" />
<add key="ClearTextPassword" value="SearchParty2017" />
<add key="AWS Nuget" value="" />


Then you can call

nuget restore


dotnet restore

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s