简体   繁体   中英

Install Nuget package using "dotnet add package -s" fail when specify private Github Nuget feed

I have a private feed from GitHub that I added to Nuget.config file:

<add key="github" value="https://nuget.pkg.github.com/..." />

I can confirm it works by using dotnet nuget list source (see screenshot below).

However when running dotnet add package -s github PackageName , it fails with "There are no versions available for the package" error. Removing the -s github works (and it installs from the Private feed if it is on the top).

在此处输入图像描述

Although I can manually run it for myself (removing -s ), I am writing a script to install it for other developers. I need to reliably install it from the private feed even if it's not on the top of the list. There may be packages in nuget.org with the same name in our private feed.

Why does specifying package source with -s not work? How do I fix it?

The Microsoft docs are saying:

-s|--source <SOURCE>

The URI of the NuGet package source to use during the restore operation.

So I'd expect the command to be like this:

dotnet add package -s https://nuget.pkg.github.com/... PackageName

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