通过客户端上传/下载NuGet组件
CodeArts Artifact支持与本地NuGet客户端对接,用户A可以通过客户端的方式将本地NuGet客户端中的私有组件上传至CodeArts Artifact私有依赖库,其他用户再通过客户端的方式从CodeArts Artifact私有依赖库下载用户A上传的NuGet组件,实现NuGet组件的共享或传递。
NuGet组件介绍
NuGet是.NET生态系统中的包管理器,它允许开发者方便地发布、分享和使用各种 .NET组件和库。NuGet制品包是这些组件和库的标准发布格式。
约束与限制
不同用户账号的私有依赖库仓库密码不同,当用户以不同账号访问私有依赖库时,如果需要使用仓库密码,则需要在各仓库“操作指导”中重新下载配置文件获取仓库密码。
前提条件
通过NuGet客户端上传组件
使用客户端工具为NuGet,请确保已安装NuGet。
- 使用华为云账号访问CodeArts Artifact的私有依赖库。
- 在私有依赖库页面选择对应的NuGet仓库。
- 单击页面右侧“操作指导”。
- 在“操作指导”对话框,“选择依赖管理工具”为“NuGet”。
- 单击“下载配置文件”,下载配置文件“NuGet.txt”。

- 打开下载的配置文件,使用如下命令,进行源的添加。
##----------------------NuGet add source----------------------## nuget sources add -name {repo_name} -source {repo_url} -username {user_name} -password {repo_password} - 使用如下命令进行包的上传,替换<PATH_TO_FILE>为要上传文件的路径,执行上传语句(若有配置源,-source后的参数可使用配置的源名称)。
##----------------------NuGet Download----------------------## nuget push <PATH_TO_FILE> -source <SOURCE_NAME>
通过NuGet客户端下载组件
使用客户端工具为NuGet,请确保已安装NuGet。
- 使用华为云账号访问CodeArts Artifact的私有依赖库。
- 在私有依赖库页面选择对应的NuGet仓库。
- 单击页面右侧“操作指导”。
- 在“操作指导”对话框,“选择依赖管理工具”为“NuGet”。
- 单击“下载配置文件”,下载配置文件“NuGet.txt”。

- 打开配置文件,找到NuGet add source下的命令,进行源的添加。
##----------------------NuGet add source----------------------## nuget sources add -name {repo_name} -source{repo_url} -username {user_name} -password {repo_password} - 打开配置文件,找到NuGet Download下的语句,替换<PACKAGE>为要下载组件的名称,执行下载语句(若有配置源,-source后的参数可使用配置的源名称)。
##----------------------NuGet Download----------------------## nuget install <PACKAGE>
通过dotnet客户端上传组件
使用客户端工具为dotnet,请确保已安装dotnet。
dotnet客户端需要添加信任服务器证书,才可以使用。
- windows信任证书步骤:
openssl s_client -connect {host}:443 -showcerts </dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' |openssl x509 -outform PEM >mycertfile.pem openssl x509 -outform der -in mycertfile.pem -out mycertfile.crtmycertfile.pem和mycertfile.crt即为下载的证书。
2.windows需要使用powershell 添加证书信任。
添加证书
Import-Certificate -FilePath "mycertfile.crt" -CertStoreLocation cert:\CurrentUser\Root
- 使用华为云账号访问CodeArts Artifact的私有依赖库。
- 在私有依赖库页面选择对应的NuGet仓库。
- 单击页面右侧“操作指导”。
- 在“操作指导”对话框,“选择依赖管理工具”为“dotnet”。
- 单击“下载配置文件”,下载配置文件“dotnet.txt”。

- 打开配置文件,找到dotnet add source下的命令,进行源的添加。
##----------------------dotnet add source----------------------## dotnet nuget add source {repo_url} add -n {repo_name} -u {user_name} -p {repo_password} - 找到dotnet upload下的语句,替换<PATH_TO_FILE>为要上传文件的路径,执行上传语句。
##----------------------dotnet upload----------------------## dotnet nuget push <PATH_TO_FILE> -s {repo_name}
通过dotnet客户端下载组件
使用客户端工具为dotnet,请确保已安装dotnet。
- 使用华为云账号访问CodeArts Artifact的私有依赖库。
- 在私有依赖库页面选择对应的NuGet仓库。
- 单击页面右侧“操作指导”。
- 在“操作指导”对话框,“选择依赖管理工具”为“dotnet”。
- 单击“下载配置文件”,下载配置文件“dotnet.txt”。

- 打开配置文件,找到dotnet add source下的命令,进行源的添加。
##----------------------dotnet add source----------------------## dotnet nuget add source {repo_url} add -n {repo_name} -u {user_name} -p {repo_password} - 找到dotnet download下的语句,替换<PACKAGE>为要下载组件的名称,执行下载语句。
##----------------------dotnet download----------------------## dotnet add package <PACKAGE>