How do I migrate source code from one TFS server to another? - tfs

We have a TFS 2005 (I think) were we host some code in one domain. Now we would like the customer do host the code by itself and they have bought a new version of TFS 2010. How do I migrate the code from the old server to the new one. We don't care about history at this point since we will have the old system running for at least one year if something critical happen.
What I have done so far is the following:
Create a master branch in the new version and copied the old version to the new version with no problem.
Created a development branch from the master branch.
Now I would like to migrate the development code from the old tfs to the new tfs and this seems complicated.
I first thought it would be as simple as checking out the whole development branch in the new TFS, delete all the files and just paste in the files from the old development branch. But that is not the case.
Maybe there are a simple tool I could use instead?

I know you said that you don't care about history but would you take it if you could get it for free? The best thing to do here is an upgrade, or an import of a Team Project Collection. If you take backups of all of your 2005 databases and restore them on the TFS 2010 data tier you can then run "tfsconfig.exe import". This is the most supported way to get your data from one server to the other.

Follow these steps in the new server:
Create the Master Branch, check-in.
Copy the sources from the old server in the local workspace of the new server at the Master Branch location
Check-in to commit the sources to the new server.
Create the Dev branch from the Master Branch using the latest changeset of the Master branch. This will replicate the whole structure of the Master branch to the Dev one.
Exit Visual Studio
Using the Windows Explorer, delete all the content of the Dev branch in the local workspace of your new server.
Copy the sources from the old server of the Dev branch in the local workspace of the new server at the Dev branch location.
Use the TFPT.EXE ONLINE command of the Team Foundation Power Tools to simulate an offline/online switch that will create the pending changes of the new content of your Dev branch (the files you copied from the old server). Be careful you have everything the way you want it to be in TFS. The command is something like tfpt.exe online /adds /deletes /modify /recurse . (check the help of the command)
Check-in.
Then you'll have the relationship between both branch and the content you want in both.

Have a look at TFS Integration Platform

Related

TFS - Branching just one project in a solution

I have solution in VS 2017 contains 4 projects - asp.net project, windows form project, SSIS project and console project. Now in WinForm project we are going to add lots of new features which we plan to release after 9-10 months, so I am thinking to create a branch for WinForm Dev branch. Here is my solution and folder structure...
MySol
MySln.sln
ConsoleApp
WebApp
WinForm (Main)
WinnFormDev (Branch)
SSIS Pkges
I successfully created Dev branch but when I open a solution in VS, I don't see my Dev branch so I can't make any change. My goal to is work in Dev branch and I may have to make some changes in WinForm main branch and other projects during 9-10 months development, I will always merge those changes in WinForm Dev, once all new features are added in Dev branch (after 9-10 months) I will merge into main and get rid off Dev branch. Is this possible? or I have to branch whole solution?
You can make changes in the Dev branch on local.
For example, I have two branches on my side:
In Visual Studio, you can first clone the repository, and then select the Dev branch here:

How to migrate a TFVC project from TFS to AZDO?

How to migrate a TFVC project from TFS to AZDO ?
Goal:
Is to migrate host projects on (TFS 2017) using TFVC, to switch them to Azure DevOps Service (AZDO) using TFVC there too.
My context:
TFS 2017 server version 2 hosting current source projects.
AZDO 2019 service wanting to host projects targeted on TFS.
Context wish:
Keep the history of source projects (TFS) on AZDO services.
I Just want to migrated the projects (TFS) in TFVC to (AZDO) in TFVC, without doing any TFVC -> GIT conversion.
I would like to avoid updating the TFS 2017 server for 2018 then to
the AZDO server to switch to AZDO services afterwards.
You understand
that is a lot of step to just want to switch a project in TFVC on
TFS2017 to a TFVC on AZDO
The easiest way to migrate is to upgrade your TFS2017 server to Azure Devops Server 2019 and then using the full fidelity import feature to upload your whole database backup to Azure Devops Service.
At the moment migration tools support TFS2018u3 as well as Azure Devops Server 2019 and 2019u1 as well as 2020 can be imported into the service. We do these kinds of imports regularly and it's a very straightforward process to restore your TFS server backup to a temporary SQL server, install the correct version of TFS/Ads and have it perform the upgrade in-place during the installation. Then use the migration tools to import the collection into Azure Devops Server. Depending on the size of your collection this may take between a couple of minutes to a couple of hours. I've done the upgrade on my laptop on certain occasions as well, installing Azure Devops Server and SQL Server Developer edition directly on Windows 10. Even a trial versions will do.
For all the details on the. Import process, see:
https://learn.microsoft.com/en-us/azure/devops/migrate/migration-import
If you want to import your tfvc project from one TFS servers to another TFS server/Azure Devops Server, you can detach the project collection on you current TFS server and bacmup/restore the database on another server. It will automatically be upgraded
If your project collection has multiple projects, you can delete the projects you don't need after attaching and upgrading your collection.
There are a few tools to perform a history replay from one server to another, those tools can't import everything, your changes id's will change and you'll lose the exact date a commit was made (and possibly the user who made the commit if that account no longer exists). Tools like:
https://www.opshub.com/products/opshub-visual-studio-migration-utility/
Depending on how old and how big your collection is, it may take many hours to migrate the data. If data has previously been deleted/destroyed or branched across projects or edited during branch operations, then the replay may fail or may be forced to perform alternative actions, some of these operations are no longer supported. I've used opshub on a couple of projects and some it completely failed to migrate, others migrated with incomplete or incorrect data. This was 4 years ago, maybe these were bugs and they were fixed, but since the import tools have been released we've used those almost exclusively.
PS: using tfs-git to convert (part of) your TFVC repo to git would be an alternative which I'd recommend you look into further. TFVC has been declared feature complete and has received very little love in the past few years. It's not supported by the new Multi-stage YAML pipelines, the integration for VS Code has been deprecated, the cross platform commandline tool for tfvc has been deprecated and therefore support for eclipse and rider and intellij as well. Team Explorer in VS 2019 is now pushed to the background with the release of the new git features which have escaped the Team Explorer window. It's clear that TFVC is fighting for a lost cause and that Git is winning, you'll need to switch over at some point.

Testing TFS upgrade by cloning the VM?

Our TFS 2017 is hosted on a virtual machine (Windows Server 2012). We are planning to upgrade the TFS to 2018. I am planning to create a clone from the VM and running the clone as a second instance with own IP, server name, etc.
I am sure that this will create a nice clone, but I am not sure if this solution is a good way to create a clone of the TFS for upgrade testing. I believe that app- and data-tier still point to the source installation.
Has anyone tried that already and can give me a hand?
You should not clone the VM. Instead clone the TFS instance. There is a procedure to follow when you clone an instance of TFS 2017.
You should make backups of TFS DBs and restore them in a different machine or VM
You should restore and prepare the DBs by changing server IDs and mapping DBs (This step is utmost important to prevent corrupting your current production TFS instance). With TFS 2018 the clone creation is made easy as the configuration wizard will take care of change server IDs and mapping DB Steps.
Configure the cloned instance of TFS.
Do not try to make a copy of the VM and get it up and running which will corrupt both instances of TFS.

How can I get the tfs server path for the local directory?

I downloaded Team Server Power Tools (TFPT) to be able to take a shelveset that was created on one branch and unshelve it on another. But for some reason, TFPT insists on asking for the target server path, which I find a bit ridiculous since it should be visible to TFPT.
A quick look around, it appears that there is an API that will state the server path, but I would rather have this available through scripting. Is there a way to get the server path through scripting?
If you have a shelveset called MyChanges on the Main branch in a Team Project called MyProject and you want to unshelve it to the Dev branch instead then the tfpt command would be:
tfpt.exe unshelve /migrate /source:"$/MyProject/Main" /target:"$/MyProject/Dev" "MyChanges"

Integrate crucible with tfs

I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.

Resources