如何在 Ubuntu 14.04 上使用 dotnet CLI 注册新的 NuGet 包源? [英] How do I register a new NuGet package source with dotnet CLI on Ubuntu 14.04?

查看:29
本文介绍了如何在 Ubuntu 14.04 上使用 dotnet CLI 注册新的 NuGet 包源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 14.04 上运行 .NET Core 1.1.0,目标是在 Ubuntu 上的 Docker 中托管我的 Web API.我想在 Ubuntu 上构建我的包,但一些 NuGet 引用托管在内部 NuGet 存储库 (Artifactory) 上.添加包源后,这在 Windows 上的 VS2015 中运行良好,但是当我运行时:

I am running .NET Core 1.1.0 on Ubuntu 14.04, with the goal of hosting my Web APIs in Docker on Ubuntu. I want to build my packages on Ubuntu, but some of the NuGet references are hosted on an internal NuGet repository (Artifactory). This works fine in VS2015 on Windows after I add the package source, but when I run:

dotnet restore

在 Ubuntu 上,托管在公共 NuGet 存储库上的软件包可以正常下载,但在 Artifactory 上的下载失败:

on Ubuntu, the packages hosted on the public NuGet repo download fine, but those on Artifactory fail:

error: Unable to resolve 'Mercury.BaseModel (>= 1.1.0)' for '.NETCoreApp,Version=v1.1'.

我在 home.nugetNuGetNuGet.Config 找到了一个 NuGet 配置文件,并添加了 Artifactory 存储库,如下所示:

I found a NuGet config file at home<user>.nugetNuGetNuGet.Config and added the Artifactory repository as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="3"/>
  </packageSources>
</configuration>

但我仍然遇到同样的错误.

but I am still getting the same error.

NuGet 本身在安装 .NET Core SDK 后不起作用,我正在使用 dotnet restore 如前所述 - 是否有类似的配置我必须为 dotnet CLI 编辑(必须使用 NuGet?)或者还有什么我需要做的吗?

NuGet itself does not work after installing the .NET Core SDK, I am using dotnet restore as mentioned - is there similar config I must edit for the dotnet CLI (which must be using NuGet?) or is there something else I need to do?

谢谢!

推荐答案

毕竟我很快就发现了我遗漏的两个问题:

After all that I quickly identified 2 problems I had missed:

  1. 我曾使用 sudo -i 以 root 用户身份运行试图解决问题,结果我在 home 文件夹中设置的 NuGet 配置没有被选中.
  2. 回到我自己的登录状态,然后出现错误:

  1. I had used sudo -i to run as root attempting to resolve the problem, as as a result the NuGet config I setup in my home folder was not being picked up.
  2. Moving back to my own logon, I then got an error:

error: Unable to load the service index for source https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local.
error:   The content at 'https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local' is not a valid JSON object.
error:   Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

事实证明,我们的 Artifactory NuGet 存储库返回符合 NuGet v2 的 XML.我更改了配置文件以将 repo 设置为 v2,它现在可以工作了.所以,从上面,编辑文件

Turns out that our Artifactory NuGet repo returns XML which is NuGet v2 compliant. I changed the config file to set the repo as v2 and it is now working. So, from above, edit the file at

home<user>.nugetNuGetNuGet.Config

添加新的存储库 URL,并正确设置版本:

adding your new repo URL, and get the version setting right:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="2"/>
  </packageSources>
</configuration>

这篇关于如何在 Ubuntu 14.04 上使用 dotnet CLI 注册新的 NuGet 包源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆