如何使解决方案成为没有映射到TFS的干净副本?问题是当我尝试打开它时会显示此消息。我想像平常一样打开它,而不需要TFS连接。
如何使解决方案成为没有映射到TFS的干净副本?问题是当我尝试打开它时会显示此消息。我想像平常一样打开它,而不需要TFS连接。
*.vssscc
和*.vspscc
的文件。.sln
文件,并查找并删除GlobalSection(TeamFoundationVersionControl)
部分。如果您想永久性地完全将解决方案与源代码控制分离,请尝试以下步骤:
下次打开解决方案时,您将不会收到连接TFS的提示。
编辑解决方案文件并从中删除以下部分。它不会完全相同但会类似。
注意:要编辑解决方案文件,请转到项目文件夹,然后使用记事本打开YouSolutionName.sln
文件。
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = <YourTFSURL>
SccLocalPath0 = .
SccProjectUniqueName1 = .
SccLocalPath1 = .
EndGlobalSection
我没有足够的声望来发表评论,但只是想补充一下Tabish的解决方案确实可以正确地从源代码控制中完全删除解决方案,特别是当TFS服务器由于某种原因无法访问时(例如,您下载了作者在上传之前未从其自己的源代码控制中删除的项目)。
然而,为了完全从项目中删除所有源代码控制痕迹,并避免在该答案的其他评论中所指出的警告(例如,“找不到解决方案的映射...”),您还必须从每个项目文件中删除以下行(显然,在早期版本的VS中,这些行存在于解决方案文件中,但在VS2017中,它们被发现在解决方案中每个项目的项目文件中-例如[project].csproj):
SccProjectName = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
SccAuxPath = "x"
SccLocalPath = "xxx"
SccProvider = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
感谢此处标记答案和其他评论指出了这一点:
visual source safe - 如何在不打开Visual Studio的情况下从解决方案中删除绑定
将此与Tabish的答案相结合,似乎是手动从源代码控制中完全移除解决方案的最完整方法。
要解除绑定,可以使用Visual Studio:菜单文件/源代码控制/高级/更改源代码控制。
您也可以通过从sln和csproj中删除任何SCC ...来自行完成。
如果您经常导出源文件,可以使用ExportSrc。 它有很多选项,例如默认情况下删除TFS绑定。
大多数答案都提供了解决方案,但我更愿意使用Visual Studio 2017提供的解决方案。
在Visual Studio的菜单栏中,选择团队并选择从Team Foundation Server断开连接即可。
Remove_TFSfiles "pathname" $booleanflag
。$false
(使用-whatif)。Remove_TFSfiles "C:\MyDevFolder" $false
$true
: "最初的回答"。Remove_TFSfiles "C:\MyDevFolder" $true
这里是函数:
Function Remove_TFSfiles {
param(
[string]$FolderName = $(throw "-FolderName is required."),
[bool]$RemoveFiles = $(throw "-RemoveFiles (either $true or $false) is required.")
)
$TFSExtensions = '*.vspscc', '*.vssscc'
if ($RemoveFiles) {
Get-ChildItem -path $FolderName -force -include $TFSExtensions -Recurse | Remove-Item -Force
# Now iterate through any solution files, and whack the TeamFoundationVersionControl section
Get-ChildItem -Path $FolderName -Filter "*.sln" -Recurse | ForEach-Object {
$slnFilename = $_.Fullname
Write-Host -NoNewline "Editing $slnFilename... "
$File = Get-Content $slnFilename -raw
$Filestr = [regex]::escape("" + $File + "")
# The regex escapes must themselves be meta-escaped, therefore "\(" becomes "\\" + "\(" = "\\\(". Did I mention I hate regex?
$Result = $Filestr -replace "\\tGlobalSection\\\(TeamFoundationVersionControl\\\).*?EndGlobalSection\\r\\n", ""
$result = [regex]::unescape($result)
Set-ItemProperty $slnFilename IsReadOnly $false
$result | Set-Content $slnFilename
Write-Host "Done"
}
Write-Host -f red "Finished actually removing files and editing *.sln files"
}
else {
Get-ChildItem -path $FolderName -force -include $TFSExtensions -Recurse | Remove-Item -WhatIf
Write-Host -f green "Finished pretending to remove files"
# Now iterate through any solution files, and whack the TeamFoundationVersionControl section
Get-ChildItem -Path $FolderName -Filter "*.sln" -Recurse | ForEach-Object {
$slnFilename = $_.Fullname
Write-Host "Not Editing $slnFilename"
}
}
}