Search code examples
visual-studionugetvisual-studio-2022nuget-package-restore

Why is Visual Studio 2022 no longer prompting me for credentials during NuGet package restore?


I have a .Net Core C# solution in Visual Studio 2022. It uses several NuGet packages that require credentials.

I had issues with incorrect credentials/passwords when attempting to restore my NuGet packages. Visual Studio was previously prompting me for credentials when restoring. Now it longer prompts me for the credentials, not giving me use my updated passwords. I tried removing/reading the packages; deleting my /bin and /obj folderds; restarting Visual Studio; restarting the machine.

Why is Visual Studio 2022 no longer prompting me for NuGet package credentials?

What do I need to do in order to start receiving the prompts again? Is there a cache of some sort?


Solution

  • I tested it in my case, and the credentials are indeed not in the credentials manager of windows.

    In my case I was able to get my login window to pop up again.

    I installed the package from devops private feed:

    nuget install ClassLibrary1 -Source https://pkgs.dev.azure.com/xxx/_packaging/xxx/nuget/v3/index.json

    After successfully logging in for the first time, there is indeed no pop-up window on my side to let me log in. When I kick out the previously authenticated user, I get the error.

    In my case, to get the login window to pop up again, two things needed to be removed:

    C:\Users\Administrator\AppData\Local\MicrosoftCredentialProvider   //If you are based on DevOps feed, delete the content in this path; if not there should be other platform tool path
    
    nuget locals http-cache --clear
    

    The first is the credential provider cache, and the second is the http cache of nuget (these two are useless to delete alone and must be deleted together).

    If you find that after deleting the above two items, it will be downloaded from the cache without popping up the login window, I suggest that you clean up the local cache written in the following document:

    Clearing local folders

    Because if the package can be obtained from the cache, the nuget command will not pop up the login window.

    To sum up, in your case credentials may be cached in platform tools. For the DevOps feed, it is the Azure Artifacts credential provider; in your case, you did not specify which platform you are using, so it may be different. Also remember to clear the https cache.