Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Monday, 14 January 2013

TFS – Workspace Mapping issues for Different Users

I have been using TFS 2010 from quite sometime now and have found it really cool! However, the management of workspaces can be a bit tricky at times.

In real scenario, many times we come across a situation when some user has to work on someone else machine and on the same project; e.g. old team member leaves the project & a new one replaces him and is allotted the same machine, a team member might leave the company, etc. 

So, the need arises to create a new workspace & map it to the same physical folder tree to avoid replication of the files at different location. (Please note : This step can be avoided if the existing workspace was a Public Workspace). While mapping the workspace to the same folder which is already mapped to the workspace of some other user, we get a message - “The working folder {PATH} is already in use by the workspace MachineName;Username on computer MachineName.” and this is by design - that we can not map the same working folder to multiple workspaces, in order to maintain the state consistency.
Now, what is the solution to this issue. The solutions are -
  1. Remove the existing mapping.
  2. Or Delete the existing Workspace.
Workspaces can be removed using some command line TFS commands. However, there are situations when we even can not remove the workspaces; reason being, the owning domain user of the workspace to be removed - “DOES NOT EXIST” and as a workaround to this, I have written a simple SQL script, which could be executed on the TFS Database of our Project to remove the mappings.
Please note that this is not a “Supported Way”. I am sharing this just because it has worked for me and might save some of your time too. Also, please take appropriate DB backup before executing the script and if possible execute it under any DBA’s guidance. So, here is the time saver script… :)
DECLARE @WorkspaceID AS INT
DECLARE @WorkspaceName AS NVARCHAR(64)
 
--Set the Name of the Workspace whose mappings are to be removed.
SET @WorkspaceName = '{NameOfWorkspace}'
 
--Get the WorkspaceID of the Workspace to be removed.
SELECT
  @WorkspaceID = W.WorkspaceId
FROM
  dbo.tbl_Workspace W
WHERE
  W.WorkspaceName = @WorkspaceName
  
--Delete the details of working folder for this workspace.
DELETE
FROM
  dbo.tbl_WorkingFolder
WHERE
  WorkspaceID = @WorkspaceID
 
 
--Delete the mapping details for this workspace.
DELETE
FROM
  dbo.tbl_WorkspaceMapping
WHERE
  WorkspaceID = @WorkspaceID

Hope, this helps you. Also, please revert if you have some other workarounds too.

Thursday, 15 December 2011

Tips and Tricks: Clipboard Ring and Toolbox Snippets


Introduction

Today I show you my favorite future in visual studio which is Clipboard Rind and Toolbox Snippets.

Implementation

1.    Clipboard Ring

Many times I wish I could go back to something I copied & pasted just a few minutes ago, then to have to go and copy the same text all over again. Turns out that Visual Studio already has this “hidden” feature.  It’s called the Clipboard Ring. 

If you copy a number of items to the clipboard, pressing [Ctrl] + [Shift] + [V] will paste the last text that was copied, but it will also highlight the pasted phrase.

Continue holding down [Ctrl] + [Shift] and press [V] again.  This will cause that highlighted section to cycle through the other items on the clipboard.  This is extremely useful when you have to copy multiple lines of separate text to a new document. 

You can also use [Ctrl] + [Shift] + [Insert] keys instead of [Ctrl] + [Shift] + [V]

2.     Toolbox Snippets

Now, you might be saying, “Great, but what if I want to save a piece of code that I use frequently in multiple places? It means same pieces of code change in multiple files. I don’t want to have to cycle through the clipboard ring every time.”  Well, there’s also a feature for that! 

If you highlight a section of code (or text) and drag it to the Toolbox, VS will create a "snippet” (not to be confused with code snippets). When u want back that code then you dragged into the VS editor or double click on that snippet it will paste in VS editor.

And last but not least these snippets also available in next day.

Screen Sot