How do I register a new NuGet package source with dotnet CLI on Ubuntu 14.04?

﹥>﹥吖頭↗ 提交于 2019-12-01 15:03:34

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

  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.
    

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

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>

Dotnet CLI restore can take -s as source feed url, so if you have Artifactory with Remote repository to nuget.org.

dotnet restore -s https://artifactory.example.com/api/nuget/nuget.org

Reference :

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!