Getting Unbound Solution from TFS

Travis Parks picture Travis Parks · Apr 5, 2012 · Viewed 7.2k times · Source

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.

Answer

d4nt picture d4nt · Feb 28, 2013

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   

}