Team Foundation Server: Move Root-Level Project - tfs

I'm trying to clean up our work-site Team Foundation Server 2010 defaultcollection.
Unfortunately we originally set it up with a whole bunch of projects at the root level of the defaultcollection.
Now we want to clean it up by moving a bunch of those projects into a root-level archive directory, while preserving the history of the projects.
This is proving extremely difficult. I've read a bunch of stuff online and run some trials, but I'm still having issues.
Part of the problem is that projects at the root level seem to be "immune" to a bunch of "normal" actions you can perform on projects in general, such as the Move command (which is greyed-out).
If I try to use the command line to perform the move like this:
tf.exe move $/TestProj $/Archive/TestProj/
I get:
TF10169: Unsupported pending change attempted on team project folder $/Test. Use the Project Creation Wizard in Team Explorer to create a project or the Team Project deletion tool to delete one.
So I figured I'd move the contents like this:
tf.exe move $/TestProj/* $/Archive/TestProj/
That worked, and history was preserved, but then when I deleted the original project like this:
TFSDeleteProject.exe /collection:MYSERVER\DefaultCollection TestProj /force
History was lost!

Those aren't "root level projects". Those are "Team Projects". There's a lot more to a team project than just source control, so, no, you can't do the same things with a "team project folder" as you could with a lower-level folder.
TFS does not use the term "project" the same way that SourceSafe did. In SS, "project" meant pretty much the same thing as "folder".

You can try the /keephistory option... as I understand it, that is supposed to allow you to do what you are trying to do.

Related

TFS - What happens if I delete a workspace?

I started work a lone developer last year and I found VSS is no longer a good option for source control so I decided to use TFS 2010 instead.
I have had to learn everything from a book - of which there are few.
I am currently creating a new build and in my workspaces I see a have 4. I want to delete one of them and rename another.
However I do not know what the consequences of doing this are. If I delete a workspace, will that remove the associated files under source control? How do I check which files these are? What happens if I change a status from active to cloaked?
As you can see, I am a beginner in all this.
Workspaces are only a mapping from SourceSontrol folders onto your local file system. Also workspace contains information about versions of the files you have locally, so when you hit 'Get Latest Version' only recent changes are sent from server to you, not the whole files. Information on what files are checked out is stored in workspace too, so if you have pending changes in the workspace and delete it then there'll be a bit of a challenge to check these changes in. Renaming of the workspace will not break anything as far as I know.
Article An introduction to TFS Workspaces may be interesting to you.
Like the others have said, the workspace only says what local files you have checked out, and the status, etc. Workspaces are pretty granulal (i.e. per user and per machine) so you could have mutliple workspaces with the same username in the same project. E.g. if you have a copy of Visual Studio at work and one at home, you could have different files checked out and you wouldn't run into any conflicts like you would have in VSS or something based on VSS Like like VSSConnect.
We've had a couple of people leave out project and have had to go in and remove their workspaces after the fact. This hasn't been a big deal in terms of any code losses but if you don't have access to the machine anymore you will have to use the TFS tools.
Try TFS Sidekicks, it provides a nice GUI to manage all the nitty-gritty back-end stuff in TFS

TFS - Refresh Team Project

My team is moving to TFS and we are currently testing migration from VSS. The VSS Converter requires all TFS projects to be created prior to conversion. We have upwards of 30 projects and it is time consuming to create these.
Is there any way to refresh the source control portion of our projects between tests (returning them to their original blank state) while leaving the projects intact, thereby allowing us to run multiple conversion tests without having to recreate our project collection and projects every time?
[Edit]
To answer John's question below: When creating a Team Project TFS, by default, creates an empty source control folder by the same name and associates it with that Team Project. The conversion file requires that source control folder to be available.
I'm going to make some assumptions.
you're using TFS 2008 or 2010
you're not afraid of the command
line :-)
I think in this scenario the "tf destroy" command is going to be your friend.
e.g. "tf destroy $/TeamProject1/FolderToBeWiped"
You could easily write a script that wipes all of your existing folders in source control. As a word of caution, DO NOT do "tf destroy $/" as this will take out the Source Control part of the team project(s) and you'll need to create it (them) again.
As a follow-up, I finally found a way to automatically create the requisite projects. Essentially the process is to drop and recreate the collection, then generate the projects from your xml mapping file. If anyone is interested I blogged it here
http://irwinj.blogspot.com/2011/05/tfsautomated-project-creation.html

How to change soure control from TFS?

I have a solution say it Myproject in vs2010. I have create a solution folder on TFS say it $/Myproject and checked in all source code files.
Now I have created another folder on TFS say it $/Myproject2 and I want to the solution Myproject in VS 2010 to connect to $/Myporject2.
I guess I should disconnect from TFS and then connect to $/Myproject2 and check in all codes, but not sure how.
So I try to go to workspace->Edit Wokrspace, and change the Source Control Folder in the list. Is it right?
Thanks.
Map your workspace to $/ and you'll be able to access both $/Myproject and $/Myproject2
However, I don't recommend having one team project be able to reference another team project. If you're going to have these types of dependencies, I would have a layout more like this:
$/MySolution
MyProject
Project.csproj
MyProject2
Project2.csproj
Where "MySolution" is the master product you are trying to build.

TFS build-server build of branch?

We have a TFS 2008 project with two branches ("Main" and "NewFeature").
Each is a complete, independent "copy" (variant) of the source code.
By changing the workspace mappings, we can map either variant onto our local PCs and have been working with both branches with no problems.
However, if I set up the mappings to switch our build server on to the NewFeature branch (which should simply swap in the NewFeature source code without changing anything else as far as the build server is concerned) I get errors:
There is no working folder mapping for $/Main/Product.sln
i.e. when it is building from the NewFeature branch, something is still looking in the Main branch, even though there are no references anywhere in the source code to this branch. It appears to be caching some reference to Main?!
I have done a completely clean build (deleted the build folder from the server and run the build with /p:ForceGet=true to make sure the mapping is flushed through to the server, and there are no files on the server that might cache the workspace bindings), but this doesn't help.
Any suggestions?
Verify that:
$(SolutionToBuild) uses a relative path when referencing Product.sln
the relative path between $/NewFeature/.../TFSBuild.proj and $/NewFeature/Product.sln is the same as it is in the Main branch.
/ EDIT /
Note, however, it's not important that $/Main and $/Branches/Feature live at the same level in the tree hierarchy. Nor should the local path on the build server matter.* All that matters is what's underneath each branch. If the contents is internally consistent then all of your existing build scripts should work without modification.
For concrete examples of how I like to tie everything together, see my past answers, e.g.:
Modular TeamBuilds
SDLC Mangement for TFS Build Scripts
Where to put my database project in TFS?
How do you share external dependencies between Visual Studio solutions?
My way is not the only way, but I can attest that it works better than all the other variations I've encountered over the years :)
*Frankly, trying to micromanage Team Build can become a lot more painful than the proposed restructuring to your MSBuild scripts. For reliability you have to place your tfsbuildservice.exe.config customizations under version control somewhere...if you own >1 build server (or might in the future) then you have to consider a change deployment strategy...you end up needing a meta-SCM process to manage your SCM process!
I also had this problem when running a build from a branch in TFS 2010. TFS was reporting that "There is no working folder mapping for $/Main/Product.sln" The solution turned out to be to edit the build definition as follows (I am using the "Default Template" build process template—I have not tried this with a custom template):
Go to the Process section/tab of the build definition.
Expand 1. Required and look for Projects to Build. Make sure this entry is pointing to the solution file inside the branch you are building.
Expand 2. Basic and look for Automated Tests. Point this to the correct test settings file in the branch being built.
OK, the results are in - I've found a workaround.
Due to our legacy build processes (build, copy, obfuscate, build custom installers, copy to drop folder), I can't easily place the branch alongside the main branch. It needs to replace it.
So, if I have Main and NewFeature, I wish to unmap Main and map NewFeature in its place (i.e. use "c:\Main" on the build server, and simply change the source code that appears there)
Solution #1 (the most simple, obvious and logical solution) is to use these mappings:
$/NewFeature -> c:\Main
Expected result: NewFeature code structure simply replaces Main, and the build server doesn't know it's on a different branch.
Actual Result: Failure with a "you haven't mapped $/Main even though you're not using it" error.
Solution #2 is to do this:
$/Main -> c:\IgnoreThisFolder
$/NewFeature -> c:\Main
This works (it suppresses the warning and thus allows the build to proceed with MSBuild unaware that it is building in a branch). However, it's ugly and the build gets all the Main branch source code unnecessarily.
Solution #3 (untested, too expensive to try unless I know it'll work much better than #2) is:
Move all the source code (from $/Main, $/Branches/Feature) to $/Branches/Main and $/Branches/Feature to get a consistent hierarchy depth, and rewrite the MSBuild script to work with these new paths.
Hope that I can then map in only the branch I need and edit TFSBuild.proj to redirect it to build in that branch.
(Edit: Yes, this works well. We have now reorganised our entire code structure so that everything (all branches) is under a common root in a single Team Project, and branching/building is no longer a problem - it's easy to do whatever we need now. The trick is to insert a root folder into the hierarchy so that you can branch at any level you like. I've added a small tweak to the build script so that we can pass the branch to build as a parameter to MSBuild, so it's easy to build any variant now. Any branches we don't want to work on can just be cloaked and the build server remains happy.)
Summary
All these solutions (to use the technical term) suck. You have to remap the workspace (in this case, it's not simple: 9 mapping entries are required so it's an error prone and tedious thing to do), edit the TFSBuild.proj, delete all the source code, and run a build with /p:ForceGet=true to switch the build between branches. So it takes about an hour to switch branches. Unbelievable - it should take a few minutes at most!
I realise our project is far from ideally set up, but I can't believe it should be this difficult to branch in TFS (It was a piece of cake in SourceSafe, Accurev, and Perforce, so why so painful in TFS?).
How does everyone else organise their TFS branches? How do you switch developers between branches? How do you switch server builds between branches? Does it really have to be this painful?
When you Edit the build definition there are two places that need to be changed.
Source Settings - Point to your new project location
Process - (This sometimes takes a while to load so be patient) Under Required, change the "items to build" location to the new solution.
Hope this helps.
New update:
As reported in the other answer, I found a workaround that was ok for a short-lived feature branch, but it really didn't work very well. I've since come back to the problem, and the full solution is ridiculously simple:
In the TFSBuild.proj, the path was based on $(BuildProjectFolderPath). This path resolves to a server-side (source control path) like $/Main - not a local path (D:\ServerBuildFolder\Main).
Unfortunately, for historical reasons our source code is split across several team projects, which means the one "branch" is fragmented into several branched folders in Source Control (i.e. $/Main/Code and $/Libraries/Code. You can't create a branch that contains $/Main and $/Libraries). We thus have to reassemble these disparate fragments from Source Control back into a coherent hierarchy using workspace mappings.
This means that Richard was spot on - the relative path from the TFSBuild.proj file to the .sln file was incorrect, because MSBuild/TFS is assuming that the .sln lies within the same Team Project and source control hierarchy (so was looking for $/Main/Libraries.sln instead of $/Libraries/Libraries.sln).
The solution is simple: I replaced $(BuildProjectFolderPath) with a local path (e.g. D:\ServerBuildFolder\Main) for the files, so that the relative reference was resolved in "local space" (after the mappings had been applied), and MSBuild is now running sweetly.
The moral of the story:
1) NEVER use more than one Team Project if there is any chance that you will ever wish to have any kind of reference between those code-bases. Don't be fooled into thinking that a new Team Project will offer some kind of painless logical distinction between applications/libraries. Extra projects have proven to just be an administration nightmare - loads of extra problems for absolutely zero benefit. (It's all one big shared pile under the bonnet, so all the work items and source control folders are still visible in all the projects (!), but it adds a few brick walls that make inter-project links very problematic)
2) Always create a single root-level folder in your Team Project source control, and then put everything else underneath that folder. e.g. For the project "$/Main", create "$/Main/Root" and then put everything from your source hierarchy inside Root.
By following these rules, you will be able to branch the single 'Root' folder in future, and will then only need a single branch and a single extra workspace mapping. This will help you avoid premature baldness.
(In my defence, I would have done it this way to begin with - I'm working with a legacy setup. In defence of the legacy setup, it sounds good on paper but just isn't a Microsoft-supported approach!)
I got this error and all I can fathom is that the definition became corrupt or something. I just redid the process stuff (re-added the solution I was trying to build) and remapped the workspaces and it started working again. HTH.

How can I migrate TFS source from one team project to another?

We've decided to go with a different template for our team project and want to move all of source under that team project. We are not concerned with migrating work items, but we would like to keep the version history of the source files, if possible. I tried the TFS to TFS migration tool on code plex and it seems to only move the most recent version of each source file over.
We are on TFS 2008 and the team projects are on the same server.
EDIT: It looks like the move function may work. I've seen some concerns posted about whether or not this moves all the history for a given file.
If you do a move from within TFS, that should register as just another action to be saved in the history. Your other history should be kept intact, even when moving across projects.

Resources