Microsoft Visual Studio asks for login endlessly - visual-studio

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

Related

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?
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.

VS Code Connect to TFS Server for Ubuntu

I use VS Community as a Developer and have spun up my own TFS Server in the past. I have been using Ubuntu more frequently and decided to try out VS Code. I started up Code and installed the Visual Studio Team Services Extension which is what I thought would be what I needed. I've read/tried online that you first have to open up a Solution which then redirects you to sign in to the web portion of their TFS/Teams which is not where my code resides. I was also not able to find the equivalent of the Team Explorer in Windows and the Plug Icon that asks you for a connection.
So my question is, how do you connect to your TFS Server and get your Projects in VS Code for Ubuntu, if possible?
UPDATE: I have gotten closer trying the following but do not have a complete solution. These steps will at least get you closer to connecting to your server.
Run Java -Version to ensure you have at least Java8 if not, run sudo apt-get install default-jre
Next download https://github.com/Microsoft/team-explorer-everywhere/releases/download/v14.114.0/TEE-CLC-14.114.0.zip
Run the command at your download location /../extract TEE-CLC-14.114.0.zip
Run this command to accept the EULA /../TEE-CLC-14.114.0/tf eula
Run this command to connect to TFS (assuming yours is the same as default) /../TEE-CLC-14.114.0/tf workspaces -collection:http://[SERVER IP HERE]:8080/tfs/defaultcollection
Sign in using AD or your Login
Run this command so you do not have to supply creds export TF_AUTO_SAVE_CREDENTIALS=1
Open VS Code > File > Preferences > Settings
On the right side is the user settings add the following "tfvc.location": "/../TEE-CLC-14.114.0/tf" and Save
Restart Code and that's all I have thus far
Below is a short list of steps to get up-and-running with TFVC support:
Install the Team Services extension for Visual Studio Code.
Team Foundation Server requires your domain credentials.
Ensure you have a TF command line client installed (either TF.exe or
the TEE CLC).
Set the tfvc.location VS Code setting to the full path of your TF
command line client.
Open a folder containing a Local TFVC Workspace and sign in when
prompted.
Set the SCM Provider to TFVC.
So your next step is opening either the root folder or a sub-folder of the TFVC repository. Detailed step you can refer to the documentation below:
https://github.com/Microsoft/vsts-vscode/blob/master/TFVC_README.md#quick-start
Also, you could check the video below which shows you how to set up the TFVC support on Windows and demonstrates much of the functionality available for Team Foundation Version Control. The features shown in this video apply equally well to the TFVC support on macOS and Linux:
https://www.youtube.com/watch?v=6IzJ2UPGmoQ&feature=youtu.be

Cannot add Application Insights - Failed to install package 'Microsoft.Web.Infrastructure'

I try to monitor the memory usage of my CloudService and stumbled upon Application Insights.
When I try to add it I get following error message:
right click on WebProject -> Add Application Insights Telemetrik
Insert Subscription-Data -> click Add-Button
Now the error occurs when VS tries to install 'Microsoft.ApplicationInsights.Web.2.0.0'
We are using VS2015 and Windows 10
Edit:
The fun thing is I can install Microsoft.ApplicationInsights.Webversion 2.0.0 via the nuget-console. But when I afterwards try to add the ApplicationInsights again it throws the same error and the package-manager-console displays:
The package at \Path\To\Project\packages\Microsoft.Bcl.1.0.14 failed to uninstall. Restart Visual Studio to finish the process.
Things you can try:
close VS, and start it once as admin. You may have old auto-updated extensions, etc that haven't been cleaned up until you run as admin. then close that admin VS and go back to your normal non-admin VS.
clear out your nuget packages in your solution, and then doing a full re-build to ensure that all of the current packages in your project are correctly and fully installed. when we try to install the AI nuget packages programmatically, Nuget tries to validate all of the existing packages and sometimes something goes wrong there validating things that already installed
then try re-adding AI through the tool.
if you still get the error, look in the directory shown in the error message, and comment and let me know if (a) that folder exists at all and (b) if it does exist, what's in it?
If things are still failing, you should be able to add the Microsoft.ApplicationInsights.Web nuget package manually from nuget package manager, and after that is done, right click the "ApplicationInsights.config" file that was added by the nuget package install, and you should see a "configure application insights" option that will let you pick your account, subscription, and AI resource, and that will get updated in the config file for you. If none of that works, you can send me a mail to jgardner # microsoft and i can try to track down more details for you.
Edit to add: If you get this error about Microsoft.Bcl, then your project is probably targeting .NET 4.0 and this is probably an issue we just found today. hypothetically, if you manually install microsoft.bcl into the project first, then that specific error for that specific package should go away? (we're working on verifying this specific dependency and fixing this asap).
A simple Visual Studio restart fixed the issue for me.

How to delete all workspaces in TFS 2010

How do I delete all workspaces on the automated build server? We had an issue where we had to keep changing the credentials on the build agent for TFS 2010, and then if we tried to deploy the build next time for all our build definitions it gave the error that the workspace already existed under a different user.
I know we can do this:
tf workspace /delete /server:http://localhost:8080/tfs/DefaultCollection 26_1_internalserver123;MYOFFICE\brian.colley
But we have to manually do that for every build definition, and we don't really know the workspace number until we try and run the build and it gives the error.
In MSDN it says you can do a /remove:, but /delete: doesn't work (or isn't even in the msdn command options which is weird). I didn't know if remove is doing something that I don't want, versus delete.
Should I do this, or will it mess up all the users in TFS on their local boxes?
c:\projects>tf workspaces /remove:* /collection:http://myserver:8080/tfs/DefaultCollection
Thanks!
Install TFS Sidekicks, you can clean them up with a nice pretty GUI.
you can filter by the build account and a machine and then delete only the specific workspaces you are interested in

TFS - Checkout File from Outside Visual Studio - Offline Mode

i have used TF.exe (Team Foundation Client) to checkout files from outside with the following command.
http://blogs.msdn.com/b/noahc/archive/2007/01/22/real-tfs-command-line-help.aspx
tf checkout $project/filename
but, i need to checkout from outside when TFS server is also not reachable. In visual studio, it prompts us to work offline and then later on, it sync automatically with the changes into server when it goes online. How do i acheive the same from tf.exe or any other way to do it.
PS: i do have real requirement of editing some files which is not belongs solution files which gets modified from outside of visual studio. as of now,i am using tf checkout method to checkout the file from outside. but, this require connection TFS server all the time.
You can't do this with the command-line tools, because the offline mode is a feature of Visual Studio, not of TFS.
The tools always work directly with the TFS, so it must be online and reachable at that time.
Amendment regarding your P.S.: What Visual Studio does in Offline mode is just setting the local files to writable and "remembering" with which files it did that. Then, on going online again, it checks for any changes in the meantime. If there were any, it starts a merge process, if there weren't, it checks out the file without getting it.
There's no reason why you couldn't do this same process by hand, it's just more comfortable through VS.
BTW: Why not have a Solution for this "dangling files"? Just create an emtpy solution and add them as Solution Items. This way you can use the VS offline mode.

Resources