Add an existing folder to TFS source control - visual-studio-2010

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.

Related

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.

How to add an existing sub-folder (with/without child files/folders) to the solution?

The folder resides within my solution physical location but I can not find a command to add existing folder to the project from right-clicking. All I can see is "Add existing files". Trying to create the folder is denied since it already exists!
I tried to move the folder out of the solution folder on the hard disk, and add it again. Thing goes fine but it turns out to be awlful if the folder is a complex folder (with lots of files and folders inside). I gave up!
You need "Include in project":
Click "Show all files", the small button at the head of your Solution Explorer, to show all files/folders of your solution. The ones not in your solution is in phantom/white color.
Right click your "existing folder" and select "Include in project"
Done
Hope that helps!

Deleting a folder in TFS

I created a folder in a TFS Project under workspace "CPortalWS". I deleted the workspace, but now I would like to delete the folder in the project and the delete option is not available.
I've tried to create a new workspace mapped to the project but I still don't get the option to delete.
Is this a bug in TFS? How can I delete the folder?
Any help would be appreciated.
Deleting a folder in TFS is a little strange.
You have to:
Create a Workspace
Get the latest source for the folder (to your local machine)
Inside Source Explorer, delete the folder
Check in your changes (this is the step that deletes the folder in Source Control)
only note that delete is not an actual delete.
the folders/files are still there and kept in Version Control, for example for Undelete scenarios.
You can see them and avail the undelete function if you go to "Tools > Options > Source Control > Visual Studio Team Foundation Server" and check "Show deleted items in the Source Control Explorer" and then right-click on one of the deleted folders.
so, if you want real delete, where the folder/files actually go away you need to use the Destroy Command which is only available from the command line, see link below
http://msdn.microsoft.com/en-us/library/bb386005.aspx
When you delete in TFS, it does not remove it from TFS. It maintains a copy of the deleted files, even when you check in the deletion. This can cause some issues.
To permanently delete from TFS, you need to issue a tfs destroy command.
To do this:
Open a Visual Studio Command Prompt.
Issue the following command: tf destroy $/SourceLocation/Folder. Where $/SourceLocation/Folder is the Source location of the deleted folder in TFS.
Please note: This command will also delete the file(s) from disk.
I had a similar issue, where I had 1 folder which despite being deleted from Hard drive, was still showing as in Source Control (with a green + by the folder). It also showed me the content but if I tried to open any, an error message informed me the file wasn't there.
Clicking on any folder didn't show the delete button. I then realised that selecting a file did! If you don't have a file, create a text file and add it to the folder you want to delete (via Source Control). Click this file, note the delete shows. Select a folder and note that the delete disappears but only after half a second. This small delay is actually usable.
I clicked the file, so the delete button is enabled and hovered the mouse above the delete button. Using the keyboard, I did a CTRL + A and as soon as all files and folders were selected I clicked left mouse button. And it worked! Everything was removed, including (and this is the odd thing) the parent folder.
Create a Workspace; and get latest on the base folder; Dont forget to cloak the relevant folders. If you are going to delete the subfolders then cloak all and get latest on the base folder. So you save a lot of time in pulling files.

How to add folders in Source Safe?

I have a static site of html and css files. It has folders on my computers. I see an 'add files' option in Source Safe 8 but it only copies files from the root folder.
How can I get Source Safe to copy the whole folder tree structure and their files?
To copy the entire directory tree, create the root folder ("Create Project") in visual source safe. Then from Windows Explorer select all files and folders you want to add to this new project (folder).
It should prompt you for a comment. Enter your note and click ok. That should add all files and folders.
If you only need to add a folder, drag the folder in to it's root in VSS. It will create the folder in VSS.
I think VSS always calls folders "projects".
Yes, drag and drop the folder, check the recursive box at the bottom where you add your comment for the initial check in. This copy all subfolders and files.
I completely agree with the suggestion of using a better option, however if Source Safe is what you use I believe its in the menus as "Create Project" to manually create folders.
Its been a bit since I've used Source Safe, but IIRC, you should be able to just drag and drop a directory into your Source Safe project and the entire tree will be added.
just drag and drop the folder from explorer into the folder in sourcesafe.

Visual Studio - how to BULK add files under a given directory as LINK?

How can one add in Visual Studio all the files under a given directory 'as link' (that is, without Visual Studio creating a local copy under current project's directory, which is what happens if one adds a folder as 'existing item')?
In my case, I don't want local copies. Instead, I want to work with existing items in their original locations. And, I don't want to add them by going through each folder. Instead, I want to specify a given folder and click a magic silver bullet button that adds all of the files below it as 'link'.
Thanks in advance.
(Disclaimer - I went through related questions, but all of them result in VS creating local copies.)
For single files
on the add item dialog you can see a small arrow pointing down on the add button
click that (since it is a button with a dropdown) and chose the add as a link menuitem. that will add the item as link
For multiple files
on the add existing items dialog SELECT all the files you want to add as an link and press the menu item ont he add button add as a link
For Multiple files in multiple locations
If you want to select a folder and add all the items on all subfolders then you can do that this way,
on the open dialog do a search for file types you want to add, select them all and do the "add item as link" action.
Since your question changed twice including the change on the title (once)
Visual Studio - how to BULK add files under a given directory as LINK?
edited title
I have added all the things i think you needs let me know if you still like to do something else
Hope this helps
Dan
If you want files under an external directory to be synced automatically in your Visual Studio project (i.e any new files are added to the solution explorer and any deleted ones are removed) then you can specify a wild card in the link. Do to this you will need to edit the project file (.csproj, .vbproj) manually though.
Find the section in the file where the ItemGroup elements are located and add something like this:
<ItemGroup>
<Content Include="..\MyDirectory\*.*" />
</ItemGroup>
This will add all files under MyDirectory (one level up from the project) to the solution automatically.
If you select 'Show all Files' in the Solution Explorer, you can than view all the files and folers and select them and right click to add them using 'Include in Project'.

Resources