views:

810

answers:

3

I have a Visual Studio 2008 solution with 7 various projects included with it. 3 of these 'projects' are Web Sites (the kind of project without a project file).

I have stripped all the various Visual Sourcesafe files from all the directories, removed the Scc references in the SLN file and all the project files that exist. I deleted the SUO file and all the USER files also. Visual Studio still thinks that 2 of the Web Sites are still under source control, and it adds the Scc entries back into the SLN file for me.

Does anybody know how VS still knows about the old source control?

Edit: Another thing that I didn't mention is that the files I'm trying to remove VSS hooks from has been copied outside of VSS's known working directories, the python script run and manual edits to files made before the solution is opened in VS 2008 or VS 2005 (I had the problem with both).

Here is a python script that I used to weed out these files and let me know which files needed manually edited.

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()
A: 

It probably is only trying to add it on your instance of VS. You have to remove the cache so VS thinks its no longer under SS

  1. under file -> SourceControl -> Workspaces
  2. Select the SS location
  3. Edit
  4. Choose the working folder
  5. Remove!
Glennular
I made a local copy of the files outside of the working directories that VSS 'knows' about and VS still somehow thinks that the Web Sites are part of a VSS project, only God knows how.
Redbeard 0x0A
+1  A: 

Those things are pernicious! Visual Studio sticks links to SourceSafe in everywhere, including into the XML that makes up your sln file.

I wrote an article about my experiences converting sourcesafe to subversion, and included with it the python script that I used to clean out the junk. Please note:

1) This is VERY LIGHTLY TESTED. Make backups so you don't screw up your sln/*proj files. Run your test suite before and after to make sure it didn't screw up something (how could it? Who knows! but stranger things have happened.)

2) This may have been with a different version of sourcesafe and visual studio in mind, so you may need to tweak it. Anyway, without further ado:

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)
llimllib
This is basically what I am doing in the 'Manual Edits', however there are no project files for a 'Web Site' in Visual Studio, so I am trying to figure out how VS 'knows' that it is part of a VSS project, even when the files were 'cleaned' outside of a VSS working directory.
Redbeard 0x0A
hmmm... sorry I've never run into that. I'd try grepping for "scc" or "source", but I'm sure you've tried that already.
llimllib
A: 

In your %APPDATA% directory Visual Studio saves a list of websites used in Visual Studio, with some settings of that site:

On my Vista Machine the exact location of the file is

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

This file contains entries like

<?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 />

As you can see it contains the Scc references that are also part of your solution file. (In this case the SCC provider is AnkhSVN 2.0, so it doesn't contain the actual SCC mapping; just some constant strings that tell the SCC provider to look at the working copy).

I think tried to fix the missing project file by caching this information in several locations. But it would be welcome if this file was properly documented.

Bert Huijben