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

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?

Check your Credentials Manager in Windows, you chould be able to remove existing credentials from there

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.

Related

Why might Visual Studio be unable to authenticate to an Azure artifact package source?

My company's NuGet feed is inaccessible via the package manager interface in Visual Studio 2022.
My company has a NuGet source with an URL like https://elcia.pkgs.visualstudio.com/_packaging/MYCOMPANY/nuget/v3/index.json. Authentication is linked to our active directory and should all just work, and has worked in the past. I can access the URL in my browser, and I can access the feed via the package manager console inside Visual Studio. nuget list -Source MYCOMPANY works just fine. But the package manager interface can't access the feed, and leaves a 401 unauthorized error in the output.
Restarting VS, restarting my machine, deleting my credentials in the credential manager have no impact.
It's somehow linked to updating my Visual Studio licence. When I choose Help => Register => Check for an updated licence it all works.

Debugging NuGet Gallery Locally does not work when calling from VS instance

I'm working on setting up my own instance of NuGet Gallery and adding Basic Authentication to the download piece. I've got that mostly sorted out, but I'm running into something I can't explain.
When I hit the api/v2/package download URL from a browser I hit all the breakpoints I would expect to hit. However, when I open up another instance of Visual Studio and set my NuGet sources to only point to my local instance of NuGet Gallery and use the NuGet Package Manager UI, the NuGet package downloads without hitting any of the break points. I have break points all over the place and I would expect the same behavior from the debugging session whether I call the URL from the browser or whether I use the NPM UI in Visual Studio.
Anyone have any ideas on what's causing this behavior?

Microsoft Visual Studio asks for login endlessly

Microsoft Visual Studio Community 2019
Version 16.4.2
Every time, something changed in my local git repository (while solution is open), or i open another solution, or at random point of time Visual Studio asks me for login, i'm entering correct login pass, and VS asks for login again after 20 secods. The process repeats endlessly.
How to avoid this repeats for login, login just once and work for a log time?
tried this, but it doesn't help https://developercommunity.visualstudio.com/t/caught-in-a-login-loop/107160
Login loop can happen if there is a Nuget package from a custom source. To verify whether this is the problem, go to
Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources
Copy and paste each source into a browser and inspect the result
If it says something like User 'xyz' lacks permission to complete this action. you may need an Azure DevOps team to give you ReadPackages permission.
I solve the problem by using credentials not from my VisualStudio, but from azure devops, where do we keep .sln
I don't know how these things are related, but it works (may be it's related to submodules some how, since few day ago we swtiched authentication for the from ssh to https. Another guess that it's because some of nuget packages are stored in feed and nuget tries to update packages source in a background.
UPDATE
Yes, the problem was related to the fact .sln used nuget packages from feed, to access them you need to authorize
In my case, I needed to log in to the source location from my browser.
I don't know why it works, but it does, the code is hosted in azure-devops.
You can disable git integrations from VSCode see Remove git integrations from VSCode
or you can use ssh key see https://learn.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops

NuGet creates read-only folders for packages without access

I am using Windows 10 with Visual Studio Community 2017. I am creating Xamarin.Forms project and right after that I am updating NuGet packages, but I see Access denied error for some NuGetpackage folders. NuGet creates these folders in c:/users/username/.nuget/packages with read-only attribute and after that it has no access to them - access denied.
Even I cannot access or manipulate these folders via File explorer, but I am with administrator account and there is no another Windows account.
I am using Visual Studio as Administrator, but I can't update/restore packages or clear NuGet cache.
In my case i have suppress the folder Cache at C:\Users\user_name\AppData\Local\Xamarin.Android for resolve this problem

Installing Nuget not working. Stating 'all specified files must reside in same workspace'

I have a solution that is on TFS, that I am not the administrator for. I have multiple microsoft accounts, and am currently signed in as one of them.
I went to solution explorer, right clicked, and 'Manage Nuget packages'. I searched for MOQ, which is currently not installed in this project. I have installed easily other Nuget packages previously, but whenever I clicked install here I get this message:
However, I only have one workspace locally, and apparently one remote one with a different name. What would cause this?
According to your error and description. This may caused by the conflict of other account's workspace on your computer. Since you have multiple microsoft accounts.
You can use tf workspace command to list the info of the workspace.
The following example displays the list of all workspaces for all users on all computers that have been created in the following team project collection at the address http://myserver:8080/tfs/DefaultCollection.
c:\projects>tf workspaces /owner:* /computer:* /collection:http://myserver:8080/tfs/DefaultCollection
Moreover, please update your NuGet to the latest version NuGet 3.3 and try again.

Resources