Getting Unbound Solution from TFS
Asked Answered
S

4

9

I have an open source project that I want to package into a .zip file containing the binaries and the source. The project is hosted on CodePlex and uses TFS as the source control. I am not sure how to export the project to remove all source control bindings. That way people can easily open the solution locally without getting a login prompt. This functionality is called Export in Git, but I'm not sure how to do the same thing in Team.

Shivaree answered 5/4, 2012 at 12:46 Comment(0)
F
11

This blog post contains the following powershell script which can be run on your source control folder and will remove the source control bindings from the files:

# Remove unnecessary files  
get-childitem . -include *.vssscc,*.user,*.vspscc,*.pdb,Debug -recurse |   
%{   
    remove-item $_.fullname -force -recurse   
}  

# Remove the bindings from the sln files  
get-childitem . -include *.sln -recurse |   
%{   
    $file = $_;   
    $inVCSection = $False;  
    get-content $file |   
    %{   
        $line = $_.Trim();   
        if ($inVCSection -eq $False -and $line.StartsWith('GlobalSection') -eq $True -and $line.Contains('VersionControl') -eq $True) {   
            $inVCSection = $True   
        }   
        if ($inVCSection -eq $False) {   
            add-content ($file.fullname + '.new') $_   
        }   
        if ($inVCSection -eq $True -and $line -eq 'EndGlobalSection') {   
            $inVCSection = $False  
        }  
    }  
    mv ($file.fullname + '.new') $file.fullname -force   
}  

# Remove the bindings from the csproj files  
get-childitem . -include *.csproj -recurse |   
%{   
    $file = $_;   
    get-content $file |   
    %{   
        $line = $_.Trim();   
        if ($line.StartsWith('<Scc') -eq $False) {  
            add-content ($file.fullname + '.new') $_   
        }  
    }  
    mv ($file.fullname + '.new') $file.fullname -force   

}
Fernery answered 28/2, 2013 at 11:33 Comment(2)
Woot Woot! I used this script to get me off TFS source control for good.Goosestep
The following criticism is aimed at MS: this ought to be a built-in feature. There's no need for such lock-in.Tours
O
5

The source control binding information is part of the VS Project and Solution files, and is difficult to remove. However, there are two options I know of:

If you "get" the project, copy/move the source folder to a different location, and then re-open the solution, VS will offer to remove the source control bindings.

Alternatively, to do this in-place, you can open the source-controlled solution in VS and then click File/Source Control/Change Source Control. This dialogue has an "Unbind" button that will remove bindings for each project.

(Caveat: tested on VS2010; not sure what version you're using.)

Onestep answered 5/4, 2012 at 13:30 Comment(3)
I am using TFS 2010. One of the problems with just unbinding is that I want to avoid copying generated obj/ and bin/ folders.Shivaree
Well, you could Get and not build before you unbind. It's possible to set up a second workspace on a single machine, and then use that just for the unbinding. (A bit of clever scripting would probably automate that easily enough, too.)Onestep
you can always clean those out before you copy. Do a Clean in Visual Studio will get some of the files, but if you want to be sure, you can add this command which will add a right click option in File Explorer to do a recursive delete on bin and obj. This example is for the .svn folders, but you can easily adapt it to your needs. weblogs.asp.net/jongalloway//shell-command-remove-svn-foldersWarrantable
L
1

Here's an alternative answer.

I copied and pasted a solution with its projects from one location to another and I am not getting prompted to connect to source control when I try to open it in the new location.

When I go to the File->Source Control->Advanced->Change Source Control, I do not have the ability unbind. So I opened the solution file in a text editor and removed the following section:

GlobalSection(TeamFoundationVersionControl) = preSolution
....
EndGlobalSection

Seems to be working; I hope it helps someone.

Laurelaureano answered 26/5, 2014 at 9:25 Comment(0)
S
0

TFS does not support exporting source code without binding. As Dan Puzey mentioned, you can just create a copy of the source control and remove the source control bindings.

For my particular project, I simply copied the files and deleted anything associated with TFS. I was doing this as part of the deployment configuration I was using with TeamCity for an open source project.

I plan on switching this project to Git as soon as it makes sense.

Shivaree answered 1/8, 2012 at 0:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.