1. 介紹
BaGet是一個輕量級的包管理服務。有些時候公司或者個人不希望某一些包進行公開,那麼就需要使用私有的包管理服務程序,該服務是用.netcore進行編寫的(感謝開發者爲社區做出的共享)
2. Docker部署
創建配置文件baget.env
# The following config is the API Key used to publish packages.
# You should change this to a secret value to secure your server.
ApiKey=63edf12c-b70c-45c7-b3ed-f53c9f791e26 # 隨機生成,上傳包時候使用
Storage__Type=FileSystem
Storage__Path=E:\nuget # windows下的寫法
Database__Type=Sqlite
Database__ConnectionString=Data Source=/var/baget/baget.db
Search__Type=Database
在當前目錄下執行
# linux
docker run -d --name BaGet-nuget -p 9002:80 --env-file baget.env -v "$(pwd)/baget-data:/var/baget" loicsharma/baget:latest
# windows
docker run -d --name BaGet-nuget -p 9002:80 --env-file baget.env -v "E://nuget//baget-data:/var/baget" loicsharma/baget:latest
3. 簡單使用
3.1 訪問
通過訪問地址: localhost:9002 進入主界面
界面和 https://www.nuget.org/ 很相似。下面我們就開始隨便創建一個類庫然後打包推送
右鍵進行打包,可以通過右鍵屬性進行修改包的參數
3.2 推送
官方提供了四種方式
下面只對其中我個人習慣的方法做示例
# .net cli
dotnet nuget push -s http://localhost:9002/v3/index.json UserLib.1.0.1.nupkg --api-key 63edf12c-b70c-45c7-b3ed-f53c9f791e26
使用cmd
注:
1.包版本要寫對
2.命令需要在包的目錄下執行
3.需要填寫baget.env文件裏面的api-key
打開網頁端查看
3.3 引用包
在我們想引用包的項目裏面打開包管理器
添加程序包源
然後搜索我們的nuget包
安裝後就可以使用了
4. 參考文檔
輕量NuGet服務—GaGet:https://mp.weixin.qq.com/s/xF5K2U3OhF7I9moGMeOibw