如何在.NET Core上注册新的NuGet包源?

时间:2018-10-25 19:15:45

标签: c# .net .net-core nuget package

我正在努力添加新的NuGet源来存储私有软件包。我有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>

also tried this,但在dotnet nuget中找不到等效项。

  

nuget源添加-Name“ MyServer”-源\ myserver \ packages

OBS:我未使用Visual Studio 2017,当前正在使用Ubuntu。

2 个答案:

答案 0 :(得分:4)

可惜的是,用户ffa没发布他们的评论作为答案,因为这是正确的。该XML应该位于名为nuget.config的文件中。

此外,如果您安装了新的dotnet SDK / CLI,则还可以运行dotnet new nugetconfig,它将为您从基本模板创建文件。如果您愿意的话,NuGet文档提供了有关how settings are applied的一些信息,但是通常人们将nuget.config文件放在其存储库的根目录中,或者与.sln文件放在同一位置。

答案 1 :(得分:0)

还有另一种方式。

dotnet add package <PACKAGE> -s <SOURCE>

问题在于,我每次想从某个特定的私人仓库中添加软件包时,都需要添加-s