How to create new root folders in a Team Project source control? - visual-studio

I'd like to recreate a folder hierarchy like in this example (from TFS Branching Guide Main 2010 v1):
The problem is I cannot understand how to create additional root-level folders, like those Development and Release in the picture above, to put new child branches into. The New Folder command option becomes available only at levels beneath root-level branches.
How to create new root folders in a Team Project source control at the Main branch level?

Make sure that your workspace maps at the Team Project level ("StandardBranchPlan" in the picture). I just tried this, and found that "New Folder" does not appear if I have the wrong workspace selected, but once I select a workspace that maps the folder under which I want to create a new folder, "New Folder" became enabled.

Here is what I did.
Connect to the desired collection in Team Explorer.
Click the down arrow at the end of the "Connect" row.
From the drop-down menu provided select "Projects and My Teams".
Select "New Team Project".
And now you have a new "Directory" under the collection root.

You cannot add a folder to root in TFS to an unmapped as mentioned. However one good way to do this is with the following example.
Scenario:
You want to have a NEW Folder to contain many NEW Projects
Right click on your solution and Add solution to source control
At this point you can create a folder on root with say name of "WebServices"
Then you continue through with the popup in adding in your project/solution
For me this works fine, although I too would prefer the freedom to setup a folder structure ahead of time for myself and other developers without having to commit/check-in code etc.

Related

Adding Whole Project to The Source Control

I can add files and folders inside a project into the source control. (Right clicking on files/folders and selecting Source Control -> Add files to Source Control)
But I can not add the whole project into source control, but the older ones are added and a lock sign are beside them. Where is the problem? How can I add the project itself to the source control so I can see the lock sign like other ones.
This may occurs if your solution is not in source control or some bindings conflict when you add that project.
Please open the solution root folder with Windows Explorer to check if the new project exists in the workspace (solution root folder) first. If the project exists, then follow below steps to add the existing project in source control.
Navigate to solution root in Source Control Explorer
Right click in Source Control Explorer and select Add items to
folder
Select the Project folder you have created, then Next
Select items to add or Excluded, then Finish
Check in the changes
Another place to check is source control bindings, simply unbind and rebind the solutions/ the project or root folders in your workspace. Detail step take a look at here: Re-establish TFS source control bindings
Normally, new project will be created in the solution root folder and the files will be added in source control automatically if the solution has already been in source control.
For any newly added project, just pay attention to Enabling Add to Source Control Option for New Project Dialog in Visual Studio
Go to the Team Explorer -> Source Control and manually add the files using the "Add Items to Folder" menu item.

TFS - How do I clone a project so I can rollback the original?

I have a project in TFS that has been live for a year. In June we made our final release (we labelled the sources) before we began a massive 3 month overhaul during which the live site would not change.
Unfortunately we are now required to make a change to the live site and the codebase has changed significantly. What I want to do ideally is check-out by label the final release (June) into another folder and check that in to TFS to create another project. This way my team can work on both projects.
How can I best achieve this?
You should create a branch. This doesn't need to be in a new project. In fact it would be better if it wasn't, however depending on your folder structure keeping it in the same project might not be an option.
Right click on the root of the folder you want to branch. This should be the folder highest in your folder structure that contains all of the code you want to modify.
On the right click menu select "Branching and Merging" and then "Branch"
Choose a sensible location for the new branch.
In the dropdown select "Label" then choose the appropriate selection.
Hit branch. This will create a new branch from the label and you will be able use the new branch to modify your live code base

TFS Get Current File Changset

I'm writing a MEF extension for Visual Studio. It's a Classifier for a custom language. I need to get the current changeset for the file - I think from TFS.
If you right-click on the file and choose properties it says "latest version" - I believe this is the latest changeset associated with the file.
I'd like to create a TFS workspace, and then get the changeset number, but I'm stumped on how to figure out the current workspace mapping from the physical path of the file in the editor.
For example, if the file is "d:\workspace\solution\random_folder\junk.txt", how do I know where the workspace for the file is mapped in TFS?
Should I just map a workspace and then search for a file called "junk.txt"? What if there is more than 1 file in different sub directories.
Thanks for any help!
You can't put one workspace beneath an existing workspace, this can't be handled correctly.
To create an additional workspace open VS and go to SourceControlExplorer. In the menu is a dropdown for Workspaces, choose "Workspaces ..." and a new dialog will open. Press the "Add.." button to create a new workspace and there you can choose which ServerPath is mapped to which local path.

How do I get Visual Studio Team Foundation Server to see I moved code to a different folder?

I moved some code from my c drive to my d drive. When I opened the solution, it told me that:
The solution appears to be under source control, but its binding
information cannot be found. Because it is not possible to recover
this missing information automatically, the projects whose bindings
are missing will be treated as not under source control.
So I tried permanently removing the bindings and downloaded the latest version. Now my changes don't register as pending changes.
I've tried selecting the solution in the Solution Explorer and File => Source Control => Change Source control, but it does not let me bind. Server Name and Server Binding columns have "".
Generally speaking, the location of code on your machine is dependent upon where your workspace is located.
If you move your workspace to the D: drive, then there shouldn't be an issue.
However, if you simply used Explorer to copy the files to the new location, then VS isn't going to be able to maintain the bindings.
From the Workspace Editor you can map the entire tree, solutions or even individual projects to a new location.
First off, put it back and undo the changes.
Then, Go to File | Source Control | Workspaces.
Click on the work space name and then the "Edit..." button.
In the working folders area select the source control folder you want to move and give it a new local folder location.
You will need to edit your Workspaces for TFS Server to know the change that has happened at your local machine. To edit your workspace, in Visual Studio:
ensure you have no pending changes; also copy your source code folder to some location temporarily, just to be safe (you can remove after you are all set)
go to Source Control Explorer
locate the "Workspace:" dropdown
select the item "Workspaces" from the dropdown list (you will get a dialog titled "Manage Workspaces"
if you have multiple Workspaces, select the appropriate one from the list in the dialog
click on "Edit" button (you will get an "Edit Workspace..." dialog)
down below in the dialog, you will see "Working folders" grid
click on appropriate row from the grid and modify the "Local folder" path to set to your new folder location
Sometimes TFS and Visual Studio have issues in getting these workspace changes synchronized. I would always close Visual Studio and re-launch it to get my changes synchronized anytime after I make Workspace related changes.
Hope this helps.
the most crude way here (I don't know if there is any other way)
is to put the folder back to its old location , Check in your changes
then remap the project to the new folder
When you move files/folders to make the moves pending changes you need to use a TFS client to do the moves.
For one or two files the Team Explorer UI is OK, for more the command line is easiest.
See tf.exe rename on MSDN (tf move is an alias for rename). There is also step by step help on using the GUI: Move, Rename, and Delete Version-Controlled Files and Folders.

Add an existing folder to TFS source control

Is there any way I can add an existing folder to source control in TFS? I have created a new folder outside of TFS, just in the file system, and would like to add it to source control, but the only apparent way to do this is the ridiculous workaround of renaming my new folder to a temp name, then creating the new folder in Source Control Explorer, then adding the items from my renamed, original new folder.
Just select the folder after selecting the "Add Items to Folder..." option. You can get to this is from the context menu you get when right clicking on a folder (either the name or the actual folder itself).
The next page of the wizard will present you with lists of included and excluded files. Select the files you want and then hit "Finish".
Then submit the pending changes.
Let me share you a easier way that I just figured out.
(I was having the same trouble, and that is why I found this post.)
Drag the folder you want to add to the solution explorer and drop at the place you want to add.
Ta Ta ! It is done.
Mine is VS2010.
Before dragging and dropping or selecting Add Items To Folder, you must map the parent TFS folder to your local drive.
That is, if you want to add a C:\Stuff\HelloWorld directory to the /Top/Projects folder in TFS, you must first map /Top/Projects to C:\Stuff and then add HelloWorld.

Resources