使用Docker 快速搭建nuget本地服务器,Hosting private nuget server using docker in seconds!

Server

#below line automatically creates the folder, mount the volumes and maps the ports.
docker run -d  -p 8080:80 -v F:/Apps/Docker/nuget/db:/var/www/db -v F:/Apps/Docker/nuget/packages:/var/www/packagefiles  -e NUGET_API_KEY=ee28314c-f7fe-2550-bd77-e09eda3d0119  sunside/simple-nuget-server
#If mapping directory meeting with errors, try using container directory directly inside of it to ensure running.

Then you get the local nuget server running at: http://localhost:8080

Client CLI using choco

choco install -y Nuget.CommandLine
# After nuget installation:
dotnet pack -c Release
nuget push -Source http://localhost:8080/ -ApiKey ee28314c-f7fe-2550-bd77-e09eda3d0119 ClassLibrary.1.0.0.nupkg
#If using dotnet core on Linux, just use below, haven't found a way to check whether a package exists on nuget server
dotnet nuget delete --source http://192.168.1.7:17071/ -k 3cdb9803-86f9-4750-9615-338f14f0c814 --non-interactive EP.${fragment} 1.0.0
dotnet nuget push --source http://192.168.1.7:17071/ -k 3cdb9803-86f9-4750-9615-338f14f0c814 EP.${fragment}.1.0.0.nupkg

Most often package is successfully pushed to server.
In visual studio, add http://localhost:8080 to nuget package source.
Then:

Package can be seen in nuget client gui.
Dont't forget to do the same to all its dependencies, and if other nuget packages referenced, remember to check the api.nuget.org source too.

Then add the package and build:

Below picture looks kind of encouraging!😃)

posted @ 2019-01-15 11:03  calochCN  阅读(1413)  评论(0编辑  收藏  举报