UPDATE Jul 15 2012: I have linked my changes at the bottom of the post so you can either grab the bin or the changed files.
Last year I wrote on how our org used tfs2svn to get us out of some jams when our TFS / SvnBridge / ReviewBoard solution was returning errors (Migrate TFS to SVN). We had been using that solution merrily while TFS 2008 Server was in play. Disaster struck when the infrastructure guys upgraded last week to TFS 2010 taking full advantage of the new TFS 2010 Collections paradigm. What the new Collections does is alter the URL so that part of the path after the domain is the collection and part is the repository path (ex: http://tfsserver:8080/tfs/collection/myProject/trunk where the “http://tfsserver:8080/tfs/collection/” part is the server and collection declaration and the “/myProject/trunk” part is the TFS repository path “$/myProject/trunk”.
When we tried to use tfs2svn again we were getting all sorts of errors such as when using the OpenTF mode:
System.Exception: Error while executing TFS QueryHistory ---> System.Xml.XmlException: '100' is an unexpected token. The expected token is "" or "". Line 20, position 65.
Or when using the MS Team Explorer mode:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version-220.127.116.11, Culture=neutral, PublicKeyToken=[string]' or one of its dependencies. The system cannot find the file specified.
What is occurring is that tfs2svn is recognizing that its TFS libraries (v18.104.22.168) are lower than the source TFS server (v10.0.0.0) and it is also programmed to take everything after the domain as the repository path which means it doesn’t handle the Collections portions of the URL. The creator, Kevin Colyar, mentioned in this post (https://sourceforge.net/projects/tfs2svn/forums/forum/772710/topic/4548185) in May 2011 that he will not be supporting the project past TFS 2008. Fortunately the source is available and some people had already made headway getting it to work with TFS 2010 (in the same post). I took what the anonymous posted mentioned and ran with it to great success.
The 2 major things we needed to fix was to update the dependency references (.Net Framework 4 and use the TFS 10.0.0.0 libraries) and to update the code to understand where the Collection part of the URL ends and the repository path part begins.
Steps in a nutshell:
- Install Visual Studio 2010 Ultimate (I grabbed the iso from the MSDN account). Takes ~45 mins.
- Run VS 2010 and select General Develpment mode if prompted.
- Download the Tfs2svn source:
svn co https://tfs2svn.svn.sourceforge.net/svnroot/tfs2svn/trunk C:tfs2svncode
- Open the project (C:tfs2svncodetrunktfs2svn.sln)
- Conversion Wizard opens:
- Create backup: No
- Summary: Finish
- In the Solution Explorer right click on each project (ex tfs2svn.Winforms) > Properties > Application tab:
- Target framework: .NET Framework 4
- Close and reopen to take effect.
- Repeat for all projects.
- Modified the tfs2svn source code (see diff).
- Built to C:tfs2svncodetrunktfs2svn.WinFormsbinRelease
- Copy SVN 1.6 (svn-win32-1.6.13) into libssvn-win32-1.6.13.
- Modified the tfs2svn.Winforms.exe.config to point to the new libssvn-win32-1.6.13
- Run tfs2svn.Winforms.exe.
The new field is available and we can distinguish between the server url and the repo path. I essentially added a new field “TFSRepo” to split out the TFS server w collection (http://tfsserver:8080/tfs/collection/) and the repository ($/myProject/trunk). I needed to add the field to the UI, config, and logic code for parsing the paths.
Note: I tried using the OpenTF 0.5.2 alpha libs but they were not working “well”. Perhaps the newer 0.6.0 will work but I didnt try. For this solution use the MS Team Explorer client libs.
Edit: Brandon (comments below) added that TFS Team Explorer needs to be installed then use the MS Team Explorer option in tfs2svn2012. Thanks for testing Brandon!
Bin and Diff
The link below is for the files changes to Rev 106. Checkout rev 106 then replace with the changed files below:
The next link is for the Built binaries. You will need to download a copy of SVN since I didnt include it:
Nice one mate.
Saved me heaps of time – even with the diff in the PDF. 😉
My pleasure, Simon. I am still trying to figure out how to attach a txt file in WordPress :S
Have you tried putting it into a zip file instead?
This looks like exactly what I need, although I am not having much luck with the pdf patch file, any chance you can email me the patch file directly.
Yeah it is garbage to copy from the PDF. I will try to get a plain txt patch file tomorrow.
You cant upload zips either as Simon suggested. I put the plain text patch file on my website and just linked from there.
Needed your mod really bad! Compiled and worked like charm!
Very big THANK YOU for sharing your work, and writing this article!
Would you be willing to provide a pre-compiled binary zipped?
I can certainly try to do that but I am not sure if you need to have TFS 2010 libraries installed. I guess this would be a good test. I probably can not host it due to the limited bandwidth that I have. Do you have an FTP or a drop box?
I’d be more than happy to provide FTP or Dropbox credentials! Feel free to email me at my email address I’ve provided in the comments, and I’d be happy you paypal you some beer/pizza cash for the time you’ve put into this.
I will send it over on Monday when I get to work. No compensation is required…this is open source after all 😀
It looks like the changes have been added to the source trunk in rev 107 http://tfs2svn.svn.sourceforge.net/viewvc/tfs2svn?revision=107&view=revision so you shouldn’t need to manually do my steps anymore 😀
I have pulled down revision 107 and see some of the changes, however, I don’t see the changes on the UI. Am I missing something?
It doesnt look like they took my changes afterall. Maybe they did not want the UI change. Their rev 107 updated the .Net framework, put SVN 1.7 binaries in, and made some minor changes to the TfsClientProvider.cs in both the OpenTFS and MSTFS packages. I think that you should still be able to use their package but you will not have the server split out from the repo. If you wish to have the UI change take the diff that I supplied and patch it against their rev 107.
I downloaded latest tfs2svn source and made file changes based on your diff file. The build got the following error. Could you please take a look? Do you have a new diff file based on the current version of tfs2svn source?
—— Rebuild All started: Project: tfs2svn.Winforms, Configuration: Debug Any CPU ——
C:tfs2svncodetfs2svn.WinFormsfrmMain.cs(216,209): error CS1061: ‘tfs2svn.Winforms.Properties.Settings’ does not contain a definition for ‘SvnBinFolder’ and no extension method ‘SvnBinFolder’ accepting a first argument of type ‘tfs2svn.Winforms.Properties.Settings’ could be found (are you missing a using directive or an assembly reference?)
Compile complete — 1 errors, 0 warnings
—— Skipped Rebuild All: Project: tfs2svn.Setup, Configuration: Debug ——
Project not selected to build for this solution configuration
========== Rebuild All: 8 succeeded, 1 failed, 1 skipped ==========
The new content of Settings.settings file I have:
<?xml version=”1.0″ encoding=”utf-16″?>
<ArrayOfString xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
I am guessing that if you took the latest tfs2svn code then there is a version mismatch between the /libs that they provide and what is in my config. It also looks as though they removed the svn binaries from the /lib folder so you may need to get those on your own now.
I really don’t know how to get old tfs2svn source. Would you please send me the tfs2svn compiled by you for TFS2010? I highly appreciate your help.
Thanks and Regards
I will see what I can do on Tuesday morning. It is currently a holiday long weekend in Canada and I am out of town away from my workstation.
Much appreciated. Really hope you enjoyed the long weekend (I had the same long weekend in Toronto:-)). Looking forwards to getting your package/more help …
Do you have the source repo with you patch file available some where to check out and build ? If not, I can add your commits to the 1.0.7 src and post it to some repo and share so folks can just check out and build locally rather going through including each diff.
I will grab it from work today and bring it home. I will host the source so that you can grab it and contrib it back. That would be great if you could!
Posted the changed code and the binaries.
Can you please let me know, whether the users, groups and roles defined in TFS will also get migrated from TFS to SVN?
@Das: this will only port over the code. You will probably need another utility for migration of admin content. If you do find such a tool please let me know!
Thanks for this Tim! Our dev team is moving from TFS 2010 to SVN and I’m the lucky guy that get to do the migration. I was struggling with finding a method that would convert the datbase over because of the Collections paradigm in TFS 2010. I spent about a day looking into TortiseSVN over SvnBridge – another unfortunately defunct project – until I found this post.
Just to confirm, I downloaded and built the source for rev 107 (your changes minus the UI) and was able to get the conversion started using the following URL format: http://:8080/tfs//
The conversion is happily chugging along as I write 🙂
Oops, silly me for using pointy brackets. Here’s the URL format:
@Andrew: Glad it helped.
I am new to subversion and I am using this tool to migrate the source code from TFS 2010 to Subversion 1.7. I have used your cusotmized binaries and have replaced them with the original ones. I do get the UI correctly now. But when i give a particular change set number for migration, i just keep getting this particular error
“2013-02-15 13:19:05,826 INFO Tfs2Svn.Tfs2SvnConverter – Adding folder D:\Repository\ePlannerNGB\\BuildProcessTemplates
2013-02-15 13:19:05,866 INFO Subversion.SvnImporter – svn add “D:\Repository\ePlannerNGB\\BuildProcessTemplates”
2013-02-15 13:19:05,906 ERROR Winforms.MainForm – Exception while converting
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at Colyar.SourceControl.Subversion.SvnImporter.RunSvnCommand(String command)
at Colyar.SourceControl.Subversion.SvnImporter.Add(String path)
at Colyar.SourceControl.Tfs2Svn.Tfs2SvnConverter.tfsExporter_FolderAdded(Int32 changeset, String path, String committer, String comment, DateTime date)
at Colyar.SourceControl.SinglePathHandler.Invoke(Int32 changeset, String path, String committer, String comment, DateTime date)
at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.AddFolder(Changeset changeset, Change change)
at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.ProcessFolderChange(Changeset changeset, Change change)
at Colyar.SourceControl.MicrosoftTfsClient.TfsClientProvider.ProcessChange(Changeset changeset, Change change)
at tfs2svn.Winforms.MainForm.DoWork(Object obj)
Can you please tell me what is going wrong here??
@Preethi: I get those every once and a while. I have a theory that TFS and SVN do not handle adds and deletes in the same order nor do they handle paths in the same order. Also, in the changeset above where you are adding a folder you may be deleting it in a later changeset causing this “The system cannot find the file specified”.
What I then do for these cases is switch to “manual” mode to get past the error then switch back to tfs2svn again. Open up the problem changeset and look at all of the changes made (adds, deletes, edits etc). Using whatever TFS management program you have, check out that particular problem changeset to another directory then copy over (or delete, edit, etc) file by file as listed in your changeset and mirror the changes into your SVN working copy. Do a diff to be sure everything is the same. Go back to your SVN working copy and run:
and make sure that working changeset mirrors the one in TFS. Grab the commit message from TFS and run:
svn commit -m “Commit message from TFS”
Go back into tfs2svn and bump the last Changeset # past the problem changeset then start it again. Hopefully that fixes it for you!
I didn’t get the correct tool for TFS 2010 to SVN.Can any one help me?
I am seeing that the last update on sourceforge tfs2svn.setp.msi was non 2013-04-29.
I am also seeing that the trunk is at 2012-02-24.
Whereas, this blog is dated 2011-12-22.
Should I download the zip listed on this web blog or the latest tfs2svn.setp.msi on source forge?
For sure grab their latest package but if it doesn’t work then you may be able to diff between theirs and what I have here. I didn’t think that the project was under active dev anymore.
The UI for their latest does not allow me to specify repo path. I do not wish to convert the whole server but just my project.
Your version which I downloaded thro a link in this blog faces the following problem:
System.Exception: svn error when executing
‘svn propset svn:author –revprop -rHEAD ASDF\Mesa Lisa “C:\projs\ccc”‘.
Exception: svn: Try ‘svn help’ for more info
svn: Wrong number of targets specified
I think the problem is due to author’s windows user name having a space. I believe it would not face that problem if the user name had been MesaLisa. There are too many authors whose username has a space.
I am looking for the portion of the code that execs the svn cmd above and put quotes around the author’s reference.
Also, they seemed to have removed rev 106, so I am unable to download it and apply your source patches.
First, big thank you !
Using your code, and also cleaning up a lot, and making it better, I managed to update tfs2svn to use it with the latest TFS, and SVN.
It is not using anymore OpenTf at all, is faster, and works better (original work did the hardest part).
If some people are interested, here is the link to the github repo, where the 2.0 release is available.
Thank you @Hartorn you saved my life. V2.0 worked like a charm on TFS2012