如何在Ubuntu 14.04上使用dotnet CLI注册新的NuGet软件包源?

编程入门 行业动态 更新时间:2024-10-28 04:17:54
本文介绍了如何在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" value="api.nuget/v3/index.json" protocolVersion="3" /> <add key="Artifactory-DEV" value="theluggage-agct.gray/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:

  • 我使用了 sudo -i 以root身份运行以尝试解决问题,结果是我在\home文件夹中设置的NuGet配置没有被拾取。
  • 回到我自己的登录,然后出现错误:

  • 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.
  • Moving back to my own logon, I then got an error: error: Unable to load the service index for source theluggage-agct.gray/artifactory/api/nuget/nuget-institutional-development-local. error: The content at 'theluggage-agct.gray/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" value="api.nuget/v3/index.json" protocolVersion="3" /> <add key="Artifactory-DEV" value="theluggage-agct.gray/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="2"/> </packageSources> </configuration>

    更多推荐

    如何在Ubuntu 14.04上使用dotnet CLI注册新的NuGet软件包源?

    本文发布于:2023-11-15 04:27:00,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1591143.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:软件包   如何在   Ubuntu   dotnet   CLI

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!