verybadcat/CSharpMath

Nightly packages using the Nuget.Config

Closed this issue · 0 comments

I've had some trouble configuring Nightly Packages. I will share what I've found out - it may help troubleshooting....

(I use Visual Studio 2019 on Windows 10.)

You may want to have the NuGet.Config part of source control, without token in the config file (especially needed if your project is shared):
The contents of the nuget config then are without a packageSourceCredentials section like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="CSharpMathNightly" value="https://nuget.pkg.github.com/verybadcat/index.json" />
    </packageSources>
</configuration>

Visual Studio should prompt for credentials
image
Here you provide your GitHub username and the token generated via https://github.com/settings/tokens.
If Visual Studio does not prompt for credentials but the logging Output shows that you did not authenticate correctly, then go to

Control Panel\User Accounts\Credential Manager

and click "Windows Credentials".
You can remove stored credentials for nuget/github there. If they become invalid, because you regenerated a token, Visual Studio does not prompt to overwrite the invalid credentials...
image

C:\Users\YOURUSERNAME\AppData\Roaming\NuGet\NuGet.Config
There already is a NuGet.Config file in the folder

C:\Users\YOURUSERNAME\AppData\Roaming\NuGet\

you may want add or delete a reference to "CSharpMathNightly" there.

Tools > Nuget Package Manager > Package Manager Settings
You can also use Visual Studio's

Tools > Nuget Package Manager > Package Manager Settings > Package Sources

to add or delete packageSources. Deleting a packageSource entry there will also delete it from your NuGet.Config files. (Having multiple nuget config files is allowed.)

Close Visual Studio on every change to the NuGet.Config
Well, just to be sure. Close Visual Studio, go to the NuGet.Config file via the file explorer and change it in something like NotePad. Then re-open Visual Studio.

Last resort?
I still had trouble even after trying things with the knowledge above. Running a search on

"Failed to download package"

led me to a StackOverflow posting and that says something about updating NuGet.exe.
After downloading the latest version of nuget.exe via https://www.nuget.org/downloads and double clicking it, everything works fine again. I think that this is a coincident: I suspect double clicking nuget.exe does nothing special. But if this didn't solve the problem, I don't know what did.

image