一 下载网址
二 需要关注的点
1.依赖框架
如果没有说明Dependencies则是仅支持NET Framework.
2.版本
3.安装(图形化和非图形化)
命令行形式:Nuget命令行(在工具栏菜单)
图形化:右键项目—Nuget包管理—搜索需要的包
关于卸载,可直接双击项目进行ItemGroup中的包信息链接删除即可卸载。
三、内部搭建Nuget服务器(一)
参考文章:Nuget私有服务器搭建 Nuget打包和发布
1.开启IIS服务器 Windows平台下 控制面板—程序和功能 开启这些项目
- 创建ASP.NET Web应用程序空项目
3.为新项目引用Nuget包:Nuget.Server
4.发布项目到本地文件夹 注意不要把项目发布包放在C盘下
5.打开IIS管理器,添加发布包部署到服务器上
6.使用Nuget Package Explorer(微软商店)进行打包上传
7.调用:点击工具 > 选择NuGet包管理 > 包管理设置>package来源>点击加号>来源填上私有的NuGet服务器地址(http://172.18.8.150:8196/nuget)
四 Baget搭建私有服
- 下载Baget Release包并上传到服务器中 https://github.com/loic-sharma/BaGet/releases
- Baget.dll 是基于.NET Core3.1 下载3.1的SDK
- 到Baget目录下执行 dotnet baget.dll 启动后台服务
- 写好类库项目,例如基于.NET6的TestNuget 功能写完直接打包
- 微软商店下载 Nuget Package Explorer,用Nuget Package Explorer打开上一步生成好的包,修改信息 必要字段ID Author Description
- 发布:File-Publish PublishUrl:http://139.196.89.233:8044/v3/index.json PublishKey:服务器中appsetting.json的Key
删除Baget包: dotnet nuget delete PackageName PackageVersion -s Url(http://139.196.89.233:8044/v3/index.json) -k apikeyself
五 通过IIS来部署Baget:
web.config:必须要添加modules两个remove模块
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<modules>
<remove name="WebDAVModule"/>
<remove name="WebDAV" />
</modules>
<aspNetCore processPath="dotnet" arguments=".\BaGet.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
appsettings.json:启用硬删除
```csharp { “ApiKey”: “albertzhaonuget”, “Urls”:”http://*:8044“, “PackageDeletionBehavior”: “HardDelete”, “AllowPackageOverwrites”: true,
“Database”: { “Type”: “Sqlite”, “ConnectionString”: “Data Source=baget.db” },
“Storage”: { “Type”: “FileSystem”, “Path”: “” },
“Search”: { “Type”: “Database” },
“Mirror”: { “Enabled”: true, // Uncomment this to use the NuGet v2 protocol //“Legacy”: true, “PackageSource”: “https://api.nuget.org/v3/index.json“ },
// Uncomment this to configure BaGet to listen to port 8080. // See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1#listenoptionsusehttps // “Kestrel”: { // “Endpoints”: { // “Http”: { // “Url”: “http://localhost:8080“ // } // } // },
“Logging”: { “IncludeScopes”: false, “Debug”: { “LogLevel”: {
"Default": "Warning"
} }, “Console”: { “LogLevel”: {
"Microsoft.Hosting.Lifetime": "Information",
"Default": "Warning"
} } } }
在IIS管理器中创建应用程序池
创建网站:IP地址那一栏可以不写,端口更改为8044
测试设置如果不通过,点击连接为,用Administrator 账户密码登录即可。
启用所有权限
推送 删除
推送 dotnet nuget push -s http://139.196.89.233:8044 -k 【apikey】 TestBagetTwo.1.0.0.nupkg
删除 dotnet nuget delete TestBaget 1.0.0 -s http://139.196.89.233:8044 -k 【apikey】
六 使用
在Visual Studio中增加Nuget源:v3/index.json是必须的。
Github ProduceTool小工具:
- albert baget list 列出远端所有的Nuget
- albert baget del -n PackageName -v PackageVersion 删除指定版本号的包
- albert baget push “我是路径” 上传指定路径下所有Nuget包到服务器上,服务器包是否允许覆盖请查阅Baget参数设置。