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

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

问题描述

我正在Ubuntu 14.04上运行.NET Core 1.1.0,目标是将Web API托管在Ubuntu上的Docker中。我想在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 repo上的软件包可以很好地下载,但是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\< user>>找到了一个N​​uGet配置文件; \.nuget\NuGet\NuGet.Config 并添加Artifactory存储库,如下所示:

I found a NuGet config file at \home\<user>\.nuget\NuGet\NuGet.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.

在安装.NET Core SDK后,NuGet本身不起作用,我使用的是 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回购返回的XML符合NuGet v2。我更改了配置文件,将存储库设置为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>\.nuget\NuGet\NuGet.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天全站免登陆