輕量級NuGet—BaGet

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 進入主界面

image.png

界面和 https://www.nuget.org/ 很相似。下面我們就開始隨便創建一個類庫然後打包推送

image.png

右鍵進行打包,可以通過右鍵屬性進行修改包的參數

3.2 推送

官方提供了四種方式

image.png

下面只對其中我個人習慣的方法做示例

# .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

image.png

注:

1.包版本要寫對

2.命令需要在包的目錄下執行

3.需要填寫baget.env文件裏面的api-key

打開網頁端查看

image.png

3.3 引用包

在我們想引用包的項目裏面打開包管理器

添加程序包源

image.png

然後搜索我們的nuget包

image.png

安裝後就可以使用了

4. 參考文檔

輕量NuGet服務—GaGet:https://mp.weixin.qq.com/s/xF5K2U3OhF7I9moGMeOibw

微信公衆號

img

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章