I try to learn Github action and packages. So, I create a sample nuget package and successfully created. However I could not use it.
I follow this step;
Click add button write organization name and add package source address like that:
After that Visual Studio doesn't ask me any credential for this address.
If there is no credential, I will expect to an error. And I got it.
[github] Failed to retrieve metadata from source 'https://nuget.pkg.github.com/[OrganizationName]/query?q=&skip=0&take=26&prerelease=false&semVerLevel=2.0.0'. Response status code does not indicate success: 401 (Unauthorized).
Then, I decide to some credential like explained in github documentation.
My nuget.config file:
However still I get Unauthorized error. And also when I click the error link gettin a message like that:
{"errors":[{"code":"Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes","message":" ['read:packages'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens."}]}
but I already have a token with read/write package credential.
So, how I add and use my private nuget packages?
How to use github nuget packages on Visual Studio 2019
First, make sure that your credential info is correct on the nuget.config
file.
I found your document suggest you should put a new nuget.config
file to your solution. This nuget.config
file is a local action file, it will act on any projects in the current subdirectory and below the current level. You can refer to this document.
In this way, you should restart VS Instance to enable this new nuget.config
file.
-------Global nuget.config--------
However, from your description and first picture, you used the global nuget.config
file. And UI's info stores under global nuget.config
file.
If you want to config this gihub package source for all the projects on your PC, you should config it on the global nuget.config
file.
And the first picture which you provided indicates that you used in the global file(C:\Users\xxx(current user)\AppData\Roaming\NuGet\NuGet.Config
).
This function also needs restart VS to enable the new nuget.config
file.
Suggestion
please add your content of the file into C:\Users\xxx(current user)\AppData\Roaming\NuGet\NuGet.Config
.
restart VS Instance or restart PC to enable this new nuget.config
file. It is designed by that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With