2009-01-22 17 views
0

我有一个Visual Studio 2008解决方案,包含7个不同的项目。这些“项目”中有3个是网站(没有项目文件的那种项目)。如何从VS网站中删除VSS挂钩?

我已经从所有目录中剥离了所有各种Visual Sourcesafe文件,删除了SLN文件中的Scc引用以及所有存在的项目文件。我删除了SUO文件和所有USER文件。 Visual Studio仍认为其中2个网站仍处于源代码控制之下,并且将Scc条目添加回SLN文件中。

有谁知道怎么样 VS还知道旧的源代码管理吗?

编辑: 我没有提到另一件事是,我试图从已复制VSS的已知的工作目录中,python脚本运行并手动编辑的文件之外,除去VSS钩子文件在VS 2008或VS 2005中打开解决方案之前制作的(我遇到了这两个问题)。

这是一个python脚本,我用它来清除这些文件,并让我知道需要手动编辑哪些文件。

import os, stat 
from os.path import join 

def main(): 
    startDir = r"C:\Documents and Settings\user\Desktop\project" 

    manualEdits = [] 

    for root, dirs, files in os.walk(startDir, topdown=False): 
    if '.svn' in dirs: 
     dirs.remove('.svn') 
    for name in files: 
     os.chmod(join(root,name), stat.S_IWRITE) 
     if name.endswith(".vssscc") or name.endswith(".scc") or name.endswith(".vspscc") or name.endswith(".suo") or name.endswith(".user"): 
     print "Deleting:", join(root, name) 
     os.remove(join(root,name)) 
     if name.endswith("sln") or name.endswith("dbp") or name.endswith("vbproj") or name.endswith("csproj"): 
     manualEdits.append(join(root, name)) 

    print "Manual Edits are needed for these files:" 
    for name in manualEdits: 
    print name 

if __name__ == "__main__": 
    main() 
+0

好奇你为什么通过python脚本完成此操作,而不是使用Visual Studio中的内置源代码管理管理来删除源代码控制绑定? – ahockley 2009-01-22 23:26:13

+0

我只能说我自己;但是为大量文件做这件事很愚蠢;您的其他选择是尝试使用Visual Studio编写脚本,并且我宁愿用勺子舀出我的眼球。或者只写一个python脚本。 – llimllib 2009-01-23 02:22:31

+0

这个特别的项目,我只需要手动编辑5个文件,所以它不是一个巨大的壮举。无论如何,你可以看看llimllib的脚本,它应该自动化我的脚本的'手动'部分。 – 2009-01-26 17:14:46

回答

1

它可能只是试图将它添加到您的VS实例。你必须删除缓存,以便VS下的文件认为其不再SS

  1. 下 - > SourceControl - >工作区
  2. 选择SS位置
  3. 编辑
  4. 选择工作文件夹
  5. 删除!
1

那些东西是有害的! Visual Studio在任何地方都粘贴到SourceSafe的链接,包括构成sln文件的XML。

我写了一个article关于我将sourcesafe转换为subversion的经验,并附带了我用来清理垃圾的python脚本。请注意:

1)这是非常轻微的测试。进行备份,以免你的sln/* proj文件搞砸了。运行你的测试套件之前和之后,以确保它没有搞砸了一些东西(它怎么可能?谁知道!但是奇怪的事情发生了。)

2)这可能与不同版本的sourcesafe和visual工作室,所以你可能需要调整它。无论如何,事不宜迟:

import os, re 

PROJ_RE = re.compile(r"^\s+Scc") 
SLN_RE = re.compile(r"GlobalSection\(SourceCodeControl\).*?EndGlobalSection", 
        re.DOTALL) 
VDPROJ_RE = re.compile(r"^\"Scc") 

for (dir, dirnames, filenames) in os.walk('.'): 
    for fname in filenames: 
     fullname = os.path.join(dir, fname) 
     if fname.endswith('scc'): 
      os.unlink(fullname) 
     elif fname.endswith('vdproj'): 
      #Installer project has a different format 
      fin = file(fullname) 
      text = fin.readlines() 
      fin.close() 

      fout = file(fullname, 'w') 
      for line in text: 
       if not VDPROJ_RE.match(line): 
        fout.write(line) 
      fout.close() 
     elif fname.endswith('csproj'): 
      fin = file(fullname) 
      text = fin.readlines() 
      fin.close() 

      fout = file(fullname, 'w') 
      for line in text: 
       if not PROJ_RE.match(line): 
        fout.write(line) 
      fout.close() 
     elif fname.endswith('sln'): 
      fin = file(fullname) 
      text = fin.read() 
      fin.close() 

      text = SLN_RE.sub("", text) 

      fout = file(fullname, 'w') 
      fout.write(text) 
0

在您%APPDATA%目录中的Visual Studio节省了在Visual Studio中使用的网站列表,该网站的一些设置:

在我的Vista机器的确切位置该文件是

C:\Users\{name}\AppData\Local\Microsoft\WebsiteCache\Websites.xml 

此文件包含像

<?xml version="1.0" encoding="utf-16"?> 
<DesignTimeData> 
    <Website RootUrl="e:\Documents\Visual Studio 2008\WebSites\WebSite\" 
     CacheFolder="WebSite" sccprovider="SubversionScc" scclocalpath="Svn" 
     sccauxpath="Svn" addnewitemlang="Visual Basic" sccprojectname="Svn" 
     targetframework="3.5" vwdport="60225" 
     _LastAccess="11-11-2008 10:58:03"/> 
    <Website RootUrl="E:\siteje.webproj\" CacheFolder="siteje.webproj" 
     _LastAccess="11-6-2008 14:43:45"/> 
    <!-- And many more --> 
</DesignTimeData /> 

由于哟项你可以看到它包含也是解决方案文件一部分的Scc引用。 (在这种情况下,SCC提供程序是AnkhSVN 2.0,因此它不包含实际的SCC映射;只是一些指示SCC提供程序查看工作副本的常量字符串)。

我认为试图通过在几个位置缓存这些信息来修复缺失的项目文件。但是,如果这个文件被正确记录,这将是受欢迎的。