标签:net pac emctl repos ted 写入 epo 几分钟 workplace
前言
Nuget是ASP .NET Gallery的一员,是免费、开源的包管理工具,专注于在.Net / .Net Core应用开发过程中第三方组件库的管理,相对于传统单纯的dll引用要方便、科学得多。其中nuget.org是最著名的Nuget公开库,但是企业内部开发的(业务)公共组件不可能都往公开库上传,所以,企业内部需要一个私有的Nuget仓库来支持。虽然微软有提供的Nuget Server,但Nuget Server用起来并不那么顺手,或者说感觉有点low。因此,本文将介绍Nexus搭建的Nuget仓库,希望能给大家多一个选择。
安装步骤
安装环境
Centos 7+, docker
mkdir -p /opt/nexus -- 创建存放nexus数据的目录
fdisk -l -- 查看硬盘信息,确定需要挂载的硬盘信息
mkfs.ext4 /dev/xvde -- 格式化硬盘
mount /dev/xvde /opt/nexus 挂载磁盘
blkid --查看硬盘信息
vim /etc/fstab --将新分区的blkid写入/etc/fstab,内容参考:
UUID={uuid} /opt/nexus ext4 defaults 0 0
保存退出,并重启机器。
重启机器。
yum update
yum install -y docker
systemctl enable docker
systemctl start docker
镜像详细说明:https://hub.docker.com/r/sonatype/nexus3/
docker run -d -p 8081:8081 --name nexus -v /opt/nexus:/nexus-data sonatype/nexus3:3.12.0
稍等片刻,可能是几分钟,通过http://serverip:8081就能访问Nexus了。
Nexus说明
登录完后,可以看到一个设置按钮:
点击Repositories,查看内置的默认仓库:
a. nuget.org-proxy
类型是proxy,表示代理仓库。我们向它请求包(package)的时候,如果本地有,它就从本地提供,如果本地没有,它会从nuget.org下载到本地,然后给我提供这个包。
b. nuget-hosted
类型是hosted,表示托管仓库。我们一般把自己开发的包上传到该仓库中。
c. nuget-group
类型是group,表示仓库组,它结合了nuget.org-proxy和nuget-hosted,能对外提供上述两者中的包。
简而言之,nuget-hosted负责包上传,nuget.org-proxy负责代理包,nuget-group负责提供包。
上传包(Package)
下载Nuget
到https://www.nuget.org/downloads下载最新推荐的nuget.exe。
添加Nuget Realms
因为Nexus认证Nuget是通过Realms来认证,因此,要添加Nuget Realms。
准备Package
编写DLL:
设置DLL信息(可选)
打包dll
方法一:使用控制台
dotnet pack -c Release
方法二:使用Visual Studio
例如,我这里是:D:\nuget push E:\WorkPlace\vs2017\Test\ErikDll\ErikDll\bin\Release\ErikDll.1.0.0.nupkg eb0497e8-5519-3f22-8e9f-f2eae720feb5 -source http://192.168.132.137:8081/repository/nuget-hosted/
Nexus上也能看到上传的package:
其中,apiKey的获取方法如下:
打开Visual Studio的Nuget管理器,进行设置
添加私有Nuget仓库地址
添加Package
调用结果
标签:net pac emctl repos ted 写入 epo 几分钟 workplace
原文地址:https://www.cnblogs.com/Leo_wl/p/9251522.html