从TFS获取未绑定的解决方案

时间:2012-04-05 12:46:09

标签: tfs export unbind

我有一个开源项目,我想将其打包成包含二进制文件和源代码的.zip文件。该项目托管在CodePlex上,并使用TFS作为源代码控制。我不知道如何导出项目以删除所有源代码控制绑定。这样人们就可以轻松地在本地打开解决方案,而无需获得登录提示。此功能在Git中称为Export,但我不确定如何在Team中执行相同的操作。

4 个答案:

答案 0 :(得分:11)

This blog post包含以下powershell脚本,该脚本可以在源控制文件夹上运行,并将从文件中删除源代码控制绑定:

# 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   

}

答案 1 :(得分:5)

源代码管理绑定信息是VS Project和Solution文件的一部分,很难删除。但是,我知道有两种选择:

如果您“获取”项目,将源文件夹复制/移动到其他位置,然后重新打开解决方案,VS将提供删除源控件绑定。

或者,要在此处执行此操作,您可以在VS中打开源控制的解决方案,然后单击“文件/源代码管理/更改源代码管理”。该对话框有一个“解除绑定”按钮,可以删除每个项目的绑定。

(警告:在VS2010上测试过;不确定您使用的是哪个版本。)

答案 2 :(得分:1)

这是一个替代答案。

我将其项目的解决方案从一个位置复制并粘贴到另一个位置,当我尝试在新位置打开它时,我没有被提示连接到源代码管理。

当我转到File-&gt; Source Control-&gt; Advanced-&gt; Change Source Control时,我没有解除绑定的能力。所以我在文本编辑器中打开了解决方案文件并删除了以下部分:

GlobalSection(TeamFoundationVersionControl) = preSolution
....
EndGlobalSection

似乎在起作用;我希望它有所帮助。

答案 3 :(得分:0)

TFS不支持在没有绑定的情况下导出源代码。正如Dan Puzey所提到的,您可以创建源控件的副本并删除源代码控件绑定。

对于我的特定项目,我只是复制了文件并删除了与TFS相关的任何内容。作为我在TeamCity中用于开源项目的部署配置的一部分,我这样做了。

我计划在有意义的时候立即将这个项目转换为Git。