I love to work on Microsoft Technologies and while working with them recently we got a challenge to migrate our project from SVN to TFS. So I would be discussing about:
1) How to migrate visual studio solution from SVN to TFS.
2) Different approaches for migration
3) Challenges faced during migrating our solution.
As it is our basic approach to first always search on google and do some analysis and research before doing any such task, similar way we did and found two approaches – Manual and Automated.
SVN2TFS.EXE – (Automated) we didn’t dig much also read few comments by which we got unhappy.
Things you should know:
#1: the product is not stable.
#2: for each action that svn2tfs is not sure to have fully reproduced, a warning will be provided to the user.
#3: for each action that svn2tfs is not able to reproduce, an exception will be thrown.
Above points have been referenced from https://svn2tfs.codeplex.com, author himself has mentioned these points. Also this application isn’t updated since 2011.Also one bug that we found is – Our TFS Server requires credentials to enter. While in this svn2tfs.exe application there is no way to enter credentials and hence we weren’t able to deploy solution on TFS with the help of this application.
SVN-GIT-TFS – (Manual) this is the best approach we liked.
I would like to thank Benjamin for his
blog post: http://sitecoreblog.blogspot.in/2014/04/migrate-from-svn-to-tfs-or-git.html
blog post: http://sitecoreblog.blogspot.in/2014/04/migrate-from-svn-to-tfs-or-git.html
We just need to follow the commands and some basic steps in order to configure Solution from SVN to TFS.
Before starting please download and configure GIT as well as Git-TF.
GIT: Download Git
TFS: Download Git-TF
After downloading Git-TF Please check whether it’s configured or not, else it won’t allow you to run commands.
Open the command prompt and enter “git-tf“
If you aren’t able to get any response then set the Environment Variable — PATH with
reference for Git-TF folder.
reference for Git-TF folder.
So, First of all checkout Solution from SVN to GIT.
Download (http://nikkipunjabi.com/svn2tfs/SVN2GIT.zip) batch file make the changes as per requirement for svnPath2Migrate and TargetGitPath (Local) and then execute it. It may ask you to provide credentials for SVN if required.
If there are more numbers of changeset (commits/versions) in solution the longer time it will take to fetch solution from SVN to GIT. It takes one commit at a time append changes and so on.
So in our project, we kept for around 17+ hours and still, it was running. So we took latest (Head Revision) Project and did Checkout in TFS.
If your solution contains a lot of versions and you don’t have enough time to wait for many days, then it will be good to commit whatever you have in local i.e. Head Revision, directly at TFS, without migrating the solution. If it doesn’t contains much changeset then you can easily migrate your project to TFS. It will also provide you the details of what files were changed with each changeset and what code changes were done.
Now for Checkin Solution from GIT to TFS.
Download (http://nikkipunjabi.com/svn2tfs/GIT2TFS.zip) batch file make necessary changes and then execute. First copy this file to a Directory where you have checkout Solution from GIT. And then execute this file from that folder where GIT Solution is present.
Note: Please try to keep the folder/file names as short as possible, at TFS as well as in Local — Keep path as much shorter as possible. For Sitecore friends, we need to be careful for TDS Items Path because the character limitation is 255 Characters. Even when we do TDS – Sync with Sitecore – Limit is 255 Characters Path.
Limitations with this approach:
1) It won’t bind the users – who did the changes won’t be identified by this, only the person whose credentials are used for migrating solution on TFS will come.
2) Date and time won’t come – On which date the changes were done will not come.
All the version history from SVN to TFS will be mapped except user and date-time.
Ideal Solution:
In order to overcome this problem, there is an option of USERMAP file which will bind the SVN usernames with TFS users. We tried with USERMAP but we were unlucky and due to time constraints we skipped it. If you are successful in mapping user via USERMAP file then do comment on this post.
Workaround:
If you have tried manual approach you will see that it has appended the user name and date-time who did the commit after the comments in the comment section. “Metadata” argument written in the command helped us to append username and date time in the comment section.
Now when you checkout your TFS solution in your local folder and when you open solution in visual studio and if you see that the version controlling is automatically changed back to SVN, then you have to change the source control for the solution.
Open the solution file and follow the below steps.
Go to File-> Source Control -> Advanced – Change Source Control
Bind all the projects with TFS
If you aren’t allowed to make changes or if it gives you error then please first of all unlock the SLN File from source control explorer and then do the above changes.
I hope this helps you in migrating solution from SVN to TFS.
If you have any other better idea or approach or suggestions then do reply in the comment.