Thursday, May 15, 2014

Forget you ever knew me

If you’re moving to a new computer at work and would like to move your C# source code from your old computer—don’t bother.  Seriously.  You’ll give your brain a boil if you try.

In what follows, I am using Visual Studio 2012.  Details may differ if you’re using a different version, but the basic answer remains constant.

To prevent the problem from ever occurring, what you want to do is check in all your changes before you give up the old computer.  On the new machine, start Visual Studio, and, on the Start Page, choose “Connect to Team Foundation Server...” instead of one of the “Recent” items:


Cruise to your project in the Source Control Explorer and select “Get Latest Version” in the right-click menu.  It’ll ask you to map your project to a local folder.  Do so.  It will then check everything out for you into the location on your new computer.  You’re done.

Unless you went ahead and copied your workspace folders over anyway, and are now extremely pissed because you keep getting this message:

If so, here’s how to fix it, even if you’ve spent the last two weeks making uncountable and unrecoverable changes to your local copies that would get you fired if you lost them.

In Visual Studio (2012), at the top of your Source Control Explorer window, you’ll see a Workspace: dropdown.  Select “Workspaces...” from the dropdown.  In the Manage Workspaces dialog that comes up, remove the workspace that you think you’re already connected to.  Workspace, not the local folder on your hard drive.

It’ll try to scare you by telling you the change is permanent.  Ignore the histrionics and just do it.

Restart Visual Studio, and as in the above steps, select “Connect to Team Foundation Server...”  It’ll treat your machine and your copied-over folder as if it were a new tree.  Get Latest Version, map your “new” local folder, resolve local conflicts if there are any, and you’re done.  The reason this works and everything else fails is because the workspace is tracked on your Team Foundation Server, and it is uniquely tied to a machine and a user.  When you copy your folders to a new machine, Visual Studio, the Team Explorer and the Source Control Explorer will conspire to make you think you’re connected—but you’re not.

Deleting (“Forget you ever knew me”) and recreating workspaces, it turns out, are trivial operations.



No comments:

Post a Comment