1. 介紹
BaGet是一個輕量級的包管理服務。有些時候公司或者個人不希望某一些包進行公開,那麼就需要使用私有的包管理服務程式,該服務是用.netcore進行編寫的(感謝開發者為社群做出的共享)
Github:https://github.com/loic-sharma/BaGet
官網:https://loic-sharma.github.io/BaGet/
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