Connect TeamCity to Visual Studio Online - tfs

I'm trying to migrate from on-premises TFS to Visual Studio Online. We have quite elaborate TeamCity build process that we don't want to migrate away from, so having TeamCity working with VSO would be ideal.
I've created alternative user credentials (as per this article) and using these credentials in TeamCity. But when I create new VCS in TeamCity, I get connection error:
TF30063: You are not authorized to access https://myproject.visualstudio.com/DefaultCollection/MyProject
I've tried my actual credentials (not alternative ones) but nothing changed - same error.
Also I've tried using alternative credentials with tf command line tool and could not enter alternative credentials - a window popped up, asking me for my LiveId.
Any idea how to fix this?
p.s. this is how TeamCity configuration look like:

To connect to Visual Studio Online you indeed need to enable alternate credentials on the account you'll use for Team City. Ensure that at least Team Explorer 2012 and update 4 is installed on the Team City server, install the whole Visual Studio 2012 incl Update 4. Team City requires at least update 2, but Microsoft only supports Visual Studio 2012 RTM and the latest update (which is update 4).
Then in the connection screen use the following information:
Repository URL: https://myaccount.visualstudio.com/DefaultCollection
Username: ##LIVEID##\your.email#live.com // Your visual Studio Online User Name, must match your LiveId.
Password: ********* // The password you setup for the alternate credentials.
You can also use the VSO Service Account credentials instead of using Alternate Credentials.
Then in your VCS Root configuration map your TFVC root in the following way:
Root: $/MyProject/Path/To/Branch/Root
Check out this post on the Jetbrains Confluence site for more details.

This has changed lately and the password needs to be generated.
Navigate to your site at https://[your project].visualstudio.com/_details/security/tokens
And generate a personal access token. And use it for password in your teamcity vcs root configuration. Username is your email.
https://streamlined.no/2016/09/19/connecting-teamcity-10-vcs-root-visual-studio-team-services/
Note: TeamCity 10 does not need the ##LIVE## workaround anymore.

I had the same problem today. The TC instance which was working fine last week mysteriously could not connect to any VCS Roots after the weekend. All VCS roots are git repos in visual studio online.
The Test Connection was failing and changing to known working user accounts still failed.
Restarting the TC service also had no impact on the problem. In the end, rebooting the whole TC Server fixed the issue. Hopefully this will help someone else out.

Well, I could not use Alternate credentials as I use it in many build configurations and it was set up to poll every 60 seconds. So I had to do much manual work to fix it up. Instead, I generated a Personal Access Token and in the Team City VCS setup for Git I entered "username" as the username and pasted the PAT into the password. That worked much better and more stable than Alternate credentials, which kept getting disabled because of background polling on behalf of Team City.

Related

nuget credentials how to tell which provider is being used?

So for "security" reasons I am forced to use a different account to run visual studio for certain admin level operations (registering COM objects mostly). TFS however only knows about my lower level regular account. In the past this hasn't been an issue and I've set credentials up for my admin account to log into TFS with the regular account.
However something has changed since I last did a password change and logging into one particular nuget feed (hosted by TFS / Azure devops server in house) from VS2019 running as admin will lock my AD account. Also my git TFS account seems not to be using the correct account. A different feed hosted by the same TFS instance (the only difference is the feed name) works fine.
I have tried setting credentials for nuget using dotnet nuget update source name -u username -p password and that hasn't helped. I suspect since git gives issues when I push to the TFS server it's using some sort of windows stored user name and password and nuget is using the same invalid credentials. I can login to TFS to search for work items in VS2019 to add on git commits so at least one provider is set correctly.
So my question is how do I find out what the actual username and credential type / provider is being used for a particular nuget feed? Ideally I'd like to find out what username it's using as well.
Please first make sure the account you were logging in with do have permission to the nuget package.
how do I find out what the actual username and credential type / provider is being used for a particular nuget feed?
You should find CredentialProvider in my local folder:
C:\Users\[username]\AppData\Local\NuGet\CredentialProviders\
Use NuGet with Azure DevOps Services feeds
Also give a try with below solution, check if this do the trick:
Right click on your solution from Solution Explorer
Manage Nuget Packages for Solution-> on top right corner click on the gear symbol -> on the left hand-side go to NuGet Package Manager
Package Sources -> on right hand-side UNCHECKED the package source you are having trouble with
Click Ok button -> restart your VS it should only ask you login once
now
.
Okay in my case it turns out different versions of nuget are in use.
The CredentialProviders folder was empty.
However I suspect an older version of nuget was involved that looks in this config file
C:\Users\<your_account>\AppData\Roaming\NuGet\NuGet.Config which in my case had the same repository name twice with slightly different casing (no idea why?) and the password was incorrect on one of those entries (they should all be the same).
So running nuget.exe sources update for the older mechanism as well as dotnet nuget update source worked. I also notice that update source requires a later version of the dotnet sdk than I happened to have specified in global.json for this project.
So I suspect this is mostly down to having
multiple versions of nuget on my machine along with a somewhat elderly dotnet sdk being in use.
The nuget repository having the same name only differing in case
I hope this helps someone else at some point.
I have marked Patrick Lu answer as correct as it actually answers my original question.

After update to Visual Studio 2019 on Mac, integration with Azure DevOps TFS server broken

After my recent upgrade to Visual Studio 2019 (?) on Mac, I am unable to connect to my TFS server using the TFS Source Control extension.
My current setup:
Visual Studio for Mac, version 8.0.3.14
Source Control Extension:
Team Foundation Version Control for TFS and Azure DevOps Version
0.4.4.5
Steps: In Team Explorer, now I see two options:
1) Add Account
2) Add Server
When I try Add Account, a dialog pops up asking for my MS credentials - I enter them as usual, and then nothing further happens, no feedback whatsoever. Is this because it thinks this account is already "added"?
When I try Add Server, I enter my azure dev ops server name, then for user name/password I enter my MS account email and password. I leave domain empty. I get a message:
"Server already exists."
Here is what I expect to see (screenshot from VS 2017 on Windows):
Instead, nothing gets populated the way it normally does in Team Explorer: Pending changes, work items, settings - the entire panel is empty:
I do switch between Windows and Mac a lot, but if I remember correctly, everything worked fine from both workspaces before, so it probably happened when I upgraded to Visual Studio 8.0.3.14 on my Mac. Any ideas on how to fix this?
I wondered the same thing but without the update process in my back pocket... meaning I haven't written any C# in a while but I'm coming back to it. I set up a project with TFS in Azure Dev Ops on my pc, then went to check it out on my Mac and couldn't find any reference anywhere to TFS. Subversion and Git are in there, but no TFS. It took a little while to find it, but here's what I found. The short answer is they want you to use Git, not TFS as TFS is not supported in VS 2019 for Mac. The article does list work-arounds.
https://learn.microsoft.com/en-us/visualstudio/mac/tf-version-control?view=vsmac-2019

TFS 2018 - Build and Release stuck on Loading

I have noticed once in a while Team Foundation Server (TFS) 2018 will get stuck on 'Loading...' whenever I go to "Builds" or "Releases" menu. This seems to be independent of the Team Project.
If I change the url of the server eventually it works:
http://mytfsserver:8080/tfs
http://mytfsserver.mydomain.net:8080/tfs
http://myalias:8080/tfs
http://myalias.mydomain.net:8080/tfs
I am TFS Admin so I should have the security rights to see everything.
There is no error message, just a "Loading..." that never goes away.
Is there a log that TFS uses?
So called Microsoft and they were able to fix the issue.
It was the account that TFS was running as. I changed from a domain account to the NETWORK SERVICE and this fixed the issue.
I have no idea why that would be the case since the domain account that I was using before had Admin rights on the local machine and on the SQL Server machine.
I also don't understand how NETWORK SERVICE was able to login to SQL server on another machine. I wonder the if logged in user is my old account. Not sure.
Well, but since then it fixed my issue. Go Microsoft Tech Support :)

how to fix Error TF30063: You are not authorized to access VS2017

I changed my password for my TFS. But when I try to reconnect I receive the TF30063 unauthorized error.
There are many issues like this and I tried everything I could find from this solution and other forums
Solve this issue by using the VS browser
The right click on the connection
The windows 10 manage user accounts edit and even the remove
Deleted every VS cache file from appdata
Deleted the whole connection in VS & tried to readd a new one
Deleted all my Internet explorer cookies, passwords cache etc.
None of them work... Can't figure out what the issue is.
PS: it works within the browser.
It should be a Visual Studio 2017 credential cached token issue. You could try below ways to clear cache:
Close all Visual Studio instances.
Delete %LOCALAPPDATA%.IdentityService.
There are some identity related caching going on in there, deleting the folder will force the identity system to rebuild its cache.
Also Clear TFS related caches %LOCALAPPDATA%\Microsoft\Team Foundation\x.0\Cache
Run Visual Studio as another user:
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
runas /netonly /user:<account> devenv.exe
Enter the user password, then Team Explorer > Manage Connections
If the issue still exists, also take a look at this blog for more ways.
Based on developer community there is a timing issue during visual studio start up that can cause the Source Control Explorer window to grab and then hang on to an invalid version of the connection to your team project. Details visit developer community.
https://developercommunity.visualstudio.com/content/problem/93366/tf30063-you-are-not-authorized-to-access-visualstu.html
Following work around steps help me to resolve the issue
Close all visual studio 2017
Start Visual studio 2017
If you see source control explorer at start up, then close source control explorer and Team explore and close visual studio 2017
Open visual studio 2017, ensure no source control explorer opened at start up
Go to View menu and click on team explorer
Then connect to TFS server.
I've gotten the above error (TF30063: You are not...) numerous times and the following three resolutions worked for me at different times:
Simplest: I've seen "Source Control Explorer" referenced numerous times, but I never leave that open. I resolved the above error by closing Team Explorer and reopening. I then loaded my solution, and then reopened Team Explorer. It opened without issues and I could contact the server (ie, I ran a code comparison in the Solution Explorer on a file I'd edited) -VS Pro 2017 v 15.8.0
Middle complexity:
I was able to reconnect with the following steps:
-Open Team Explorer (View menu => Team Explorer)
-Click "Manage Connections" which is the plug shaped button at top
-Click the text "Manage Connections" which is actually a drop down menu
-Select "Connect to a Project"
This brings up a new window that shows hosted repositories for your account. After several seconds the window displayed the desired projects. I just had to click the desired one and click the "Connect" button at the bottom. Once I did this, I was able to access all TFS features (ie I checked in some work) -VS Enterprise 2017 v15.9.3
Last resort:
I loaded VS2017 Community onto another machine and logged in on that machine using my regular login. I'm not sure why, but as soon as I logged in on this new installation my other two computers had no problem connecting. No additional steps were needed, though I may have restarted VS on those machines.
I will be facing this issue every six times a year. Because domain account password gets expired every 2 months 0 days or 8 weeks 5 days or 61 calendar days interval due to business security policy.
Follow these steps to change/set Password of TFS from IDE
Delete TeamExplorer.config from
%AppData%\Microsoft\VisualStudio\15.0_xxxxxxxx\Team Explorer.
(So after establishing a successful connection, it'll try to recreate
again with the same data)
Add or change the TFS account Credential from Windows Credential Manager. So it won't prompt to enter a password again whenever when a connecting is established from IDE to TFS
If the above doesn't work close the Visual Studio IDE. Delete all the files inside %LocalAppData%\.IdentityService and %LocalAppData%\Microsoft\Team Foundation\7.0\Cache and on elevated prompt execute runas /netonly /user:<user domain account> devenv.exe navigating from "C:\Program Files (x86)\Microsoft Visual Studio\2017\<Professional>\Common7\IDE\"
I had this same problem, and the solution I finally found was when VS asked if this was a "Work or school account" or a "Personal account" I chose "Personal account", and that fixed it even though it is a work account. This used to work fine, but it seems with some recent updates it causes an issue if you select "Work or school account"
I also had this problem with VS2017, version 15.9.4.
Common fixes are detailed here and here. And the majority of pages talking about this problem reference those solutions or sub-sets in some combination or another. (And often to fix login bugs introduced in one of the 15.5.* versions of VS2017)
None of those solutions worked for me either and after researching for 2 days, I found a couple of fringe-reasons why VS 2017 will not refresh/store credentials.
The 2 main "fringe" problems/fixes I've found are:
Connecting through certain proxy setups
Cryptography store not allowing for local storage, see also here
For myself it was the second problem, a good indicator of the issue is a log entry in %TEMP%\servicehub\logs with the error: "The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation."
It might also be a Windows 7/8.1 known issue carried over to Windows 10 upgraded machines. The problem only happened on a machine that joined the domain after doing the Windows 10 upgrade.
The fix is to add the following registry entry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb]
"ProtectionPolicy"=dword:00000001
Setting that immediately fixed the issue with VS2017 connecting to the Microsoft Account. (And some other applications that would not persist credentials between launches)
After you have tried making changes to default browser and installing new browser like firefox or chrome, if still doent work, then you might have to check with network team of your organization on proxy settings that should be allowed in internet options. We have tried the above and it worked.
Maybe this only happened to me but I always used the wrong credentials (wrong username or wrong password). On Windows 11 I was only using my PIN, so it took automatically a user and password. I had to use different credentials to change my name and password.

Clear stored TFS credentials in Visual Studio 2017

I had to change my password for my account which is not the same account i log into my machine with. When connected to the local tfs server, I supplied my password to VS2017 and checked remember password. Now that the password has changed, I cannot connect.
I have tried to remove the tfs in credential manager and also deleted the .IdentityService. Neither have helped. Anyone know if they changed something with VS 2017 and they are cached or stored somewhere else?
Please try below items to narrow down the issue:
Remove the TFS related credentials from Credential Manager
In Credential Manager add the new updated Generic Credentials for the TFS account.
Generally, this would overwrite the cached credentials.
Close all Visual Studio instances, delete
%LOCALAPPDATA%\.IdentityService as you did.
Clear TFS caches %LOCALAPPDATA%\Microsoft\Team Foundation\7.0\Cache
Clear all the browser caches especially for the stored password
Restart Visual Studio > Team Explorer > Manage Connections to check
if the Enter credential dialog popup. Just try this several times.
Based on my test the dialog will popup the first time, but if you cancel
it, then you have to restart VS to popup it again.
Run Visual Studio as another user:
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
runas /netonly /user:<account> devenv.exe
Enter the user possword, then Team Explorer > Manage Connections
I tried to follow the steps listed in the other answer.
But on first step I decided to try just editing the password in credentials manager. It worked for me.
So if anyone else is having the same problem you might want to try that first.
Clear the config from the following path:
C:\users\<user>\AppData\Roaming\Microsoft\VisualStudio\15.0_????\Team Explorer\
These Steps worked for the issue : The V2 feed returned an unexpected status code '403 Forbidden' for configured nuGet package through Artifactory
Remove the TFS related credentials from Credential Manager
1)In Credential Manager add the new updated Generic Credentials for the TFS account. 2)Generally, this would overwrite the cached credentials.
Close all Visual Studio instances, delete %LOCALAPPDATA%.IdentityService as you did.
Clear TFS caches %LOCALAPPDATA%\Microsoft\Team Foundation\7.0\Cache
Clear all the browser caches especially for the stored password
Restart Visual Studio > Team Explorer > Manage Connections to check if the Enter credential dialog popup. Just try this several times. Based on my test the dialog will popup the first time, but if you cancel it, then you have to restart VS to popup it again.
I had face a typical problem with Visual Studio 2017. I was using VSTS. First time i had connected With one credential, later on i was trying to change credential. But it was not taking. Then after a long effort finally i found there have a folder.
C:\Users\ {your user name} \AppData\Local\GitCredentialManager
just delete all the file inside this folder and try. Hope it will work.
I had an issue where TFS kept connecting with the wrong credentials.
The solution that worked for me was to run the following command line:
tf vc workspaces /login:MY_USERNAME /collection:http://TFS_SERVER_PATH
In Windows search for Manage Your Network Passwords, from there you can delete and modify saved credentials
In our case, we had to change the user account to log into TFS on the same machine.
None of above solutions did not work for us except changing the computer name.
Other answers didn't work for me.
Goto File->Account Settings->All Accounts remove the account you want.

Resources