The pits encountered in TFS extension development

Source: Internet
Author: User

This code farm recently developed a vs extension, some of which are related to file checkout. Our company is using TFS, encountered some peculiar phenomenon, the resolution process is recorded as follows.

One, clearly online connection but offline attribute equals True

  Public StaticWorkspace Getworkspace (stringSlndir) {            varProjectcollections =NewList<registeredprojectcollection>( (Registeredtfsconnections.getprojectcollections ())); varOnlinecollections = Projectcollections.where (c =!)c.offline).            ToList (); //fail if there is no registered collections that is currently on-line            if(!Onlinecollections.any ()) {                return NULL; } Workspace Workspace=NULL; //find a project collection with at least one team project            foreach(varRegisteredprojectcollectioninchonlinecollections) {                varProjectCollection =tfsteamprojectcollectionfactory.getteamprojectcollection (registeredprojectcollection);                Projectcollection.ensureauthenticated (); varVersionControl = (versioncontrolserver) projectcollection.getservice (typeof(Versioncontrolserver)); varTeamprojects =NewList<teamproject> (Versioncontrol.getallteamprojects (false)); //If there is no team projects in this collection, skip it                if(Teamprojects.count <1)Continue; varDIR =NewDirectoryInfo (Slndir);  while(Workspace = =NULL) {Workspace=Versioncontrol.trygetworkspace (dir.                    FullName); if(dir. Parent = =NULL)                         Break; Dir=dir.                Parent; }                if(Workspace! =NULL&&Workspace. Hasusepermission) Break; }            returnWorkspace; }

The phenomenon is that the above code

var onlinecollections = Projectcollections.where (c =!c.offline). ToList ();

I can't find the one I want. Online TFS Server

The first attempt to delete the cache in the Local AppData (C:\users\*\appdata\local\microsoft\team Foundation) does not work.

Then find the registry

hkey_users\s-1-5-21-2532103873-3336248781-2863026242-1503\software\microsoft\visualstudio\11.0\teamfoundation\ Instances\tfs.yintai.org\collections\platformcollection
Change this node offline to 0

OK.

The cause is unknown and may be related to multiple TFS connections.

Second, the Trygetworkspace method can not find the corresponding workspace

And then you meet

Workspace = Versioncontrol.trygetworkspace (dir. FullName);

Always returns null

Instead, use the Queryworkspaces method to traverse all workspace to resolve

Put this paragraph

var New DirectoryInfo (slndir);                  while NULL )                {                    = versioncontrol.trygetworkspace (dir. FullName);                     if NULL )                        break;                     = dir. Parent;                }

Replaced by

  Try{workspace[] workspaces= Versioncontrol.queryworkspaces (NULL, Environment.username, Environment.MachineName); foreach(varWsinchworkspaces) {                        foreach(varFolderinchws. Folders) {if(Slndir.startswith (folder. Localitem)) {workspace=ws;  Break; }                        }                        if(Workspace! =NULL&&Workspace. Hasusepermission) Break; }                }                Catch                {                    Continue; }

  

The pits encountered in TFS extension development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.