简体   繁体   中英

How to register new NuGet package source on .NET Core?

I'm struggling to add new NuGet source to store private packages. I have already tried to add config into my .csproj like this post suggests

<?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>

I also tried this but was not able to find an equivalent in dotnet nuget .

nuget sources Add -Name "MyServer" -Source \\myserver\\packages

OBS: I'm not using Visual Studio 2017 and currently using Ubuntu.

It's a shame that the user ffa didn't post their comment as an answer, because it's correct. The XML is supposed to be in a file named nuget.config .

Also, if you have a newish dotnet SDK/CLI installed, you can also run dotnet new nugetconfig and it will create the file from a basic template for you. NuGet docs have some information about how settings are applied if you care, but generally people put their nuget.config files in the root of their repository, or in the same place as their .sln file.

There is another way.

dotnet add package <PACKAGE> -s <SOURCE>

The problem is that I need to add -s every single time I want to add a package from a certain private repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM