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.
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
}
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.)
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.
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.
© 2022 - 2024 — McMap. All rights reserved.