-
I am trying to use the basic .NET Core Github workflow as shown here, but I am having trouble with nuget. When the workflow gets to the Install Depedencies which performs a donet restore, it keeps getting 403s and 401 errors when running on my WebAPI repo here. I have tried using, {{secrets.GITHUB\_TOKEN}}, {{secrets.PERSONAL_ACCESS_TOKEN}} with repo and read package permissions and using the actual token instead of the secret reference. How do I fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
In the " nuget.config" file, I see you set the Credentials like as below:
You should not directly call the secrets in the " nuget.config" file, you need to set the secrets as environment variables at first, then call the environment variables in the " nuget.config" file.
Typically, you can directly use the secrets in the value of the with key. For example:
Other situations, such as in the command lines or in the config/settings files, you’d better set the secrets as environment variables at first. More details, you can reference the docs about Secrets. |
Beta Was this translation helpful? Give feedback.
-
How are things going? Is my suggestion helpful to you? Please try it, and any progress, feel free to tell me. |
Beta Was this translation helpful? Give feedback.
-
I haven’t had the chance to try it yet. This is a hobby app I work on, on the weekends. I’ll update you then. But your solution looks promising. Thanks |
Beta Was this translation helpful? Give feedback.
-
Okay, any update, feel free to tell me. |
Beta Was this translation helpful? Give feedback.
-
I made the changes you reccomended and I am still getting 401s. Do you have any other sugesstions? |
Beta Was this translation helpful? Give feedback.
-
How about " <add key=“ClearTextPassword” value="%GITHUB_TOKEN%" />"? I tested, it can work fine, see the example here: https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/TestNuGet/nuget.config https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/TestNuGet/TestNuGet.csproj https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/.github/workflows/CI.yml |
Beta Was this translation helpful? Give feedback.
-
Hi I changed it to that and it appears to work but now I am getting error NU1101: Unable to find package Microsoft.EntityFrameworkCore. No packages exist with this id in source(s): github Which I assume is because my nuget.config does not reference nuget.org Edit: I fixed it and it is now building, thank you. |
Beta Was this translation helpful? Give feedback.
@radulfr96 ,
How about " <add key=“ClearTextPassword” value="%GITHUB_TOKEN%" />"?
I tested, it can work fine, see the example here:
https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/TestNuGet/nuget.config
https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/TestNuGet/TestNuGet.csproj
https://github.com/TestGitHubPackagesRML/TestNuGet/blob/master/.github/workflows/CI.yml