Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Utility for removing SourceSafe bindings?

I'm looking for a utility that will remove SourceSafe bindings automatically given the location of the solution file. I found several mentions of this tool:

http://codebetter.com/blogs/darrell.norton/archive/2008/05/16/sourcesafe-binding-remover.aspx

That looks like exactly what I need - deletes .scc files and modifies .sln and .*proj files. However, I can't figure out how to actually get the utility - the attachment on that post seems to not actually be there.

Does anyone have a copy of this tool or know where I can find something similar before I rewrite it myself? I have 137 solutions to de-bind so doing this manually is not an attractive option.

like image 547
shampoopy Avatar asked Dec 17 '22 07:12

shampoopy


2 Answers

I wrote this type of utility not too long ago and you are on the right track with what needs to be done.

Here's some code to get you started. It should work for all .Net projects (VS 2003 - VS 2008) including deployment projects:

//get list of all files to be edited/removed
            SlnFiles = new List<FileInfo>(SelectedDir.GetFiles("*.sln", SearchOption.AllDirectories));
            ProjFiles = new List<FileInfo>(SelectedDir.GetFiles("*.*proj", SearchOption.AllDirectories));
            VssFiles = new List<FileInfo>(SelectedDir.GetFiles("*.vssscc", SearchOption.AllDirectories));
            VssFiles.AddRange(SelectedDir.GetFiles("*.vsscc", SearchOption.AllDirectories));
            VssFiles.AddRange(SelectedDir.GetFiles("*.scc", SearchOption.AllDirectories));
            VssFiles.AddRange(SelectedDir.GetFiles("*.vspscc", SearchOption.AllDirectories));

Deleting VSS files

//Delete all vss files
            VssFiles.ForEach(vss =>{vss.Delete();});

Editing sln files

//Edit sln files 
    SlnFiles.ForEach(sln =>
    {
    string fullName = sln.FullName;
    string relPath = sln.Directory.FullName.Replace(workingDir.FullName, string.Empty);

    StreamReader reader = sln.OpenText();
    String text = reader.ReadToEnd();
    reader.Close();
    string regex = "\tGlobalSection\\(SourceCodeControl\\) [\\s\\S]*? EndGlobalSection\r\n";
    RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
    Regex reg = new Regex(regex, options);

    text = reg.Replace(text, string.Empty);
        if (text.StartsWith(Environment.NewLine))
            text = text.Remove(0, 2);
        StreamWriter writer = new StreamWriter(fullName);
        writer.Write(text);
        writer.Flush();
        writer.Close();
    });

Editing proj files

//edit proj files
    ProjFiles.ForEach(proj =>
    {
    string fullName = proj.FullName;
    string relPath = proj.Directory.FullName.Replace(workingDir.FullName, string.Empty);

    StreamReader reader = proj.OpenText();
    String text = reader.ReadToEnd();
    reader.Close();

    string regex = "\"*<*Scc.*?(>|\\W=\\W\").*?(>|\")";
    RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
    Regex reg = new Regex(regex, options);

    text = reg.Replace(text, string.Empty);
    StreamWriter writer = new StreamWriter(fullName);
    writer.Write(text);
    writer.Flush();
    writer.Close();
    });
like image 60
Jeremy Avatar answered Dec 21 '22 23:12

Jeremy


Here's the link to a newly created VSSBindingRemover. The software has been created based on Jeremy's and juanjo.arana's answers. You can download the source code and the executable from the GitHub.

like image 38
Mikael Koskinen Avatar answered Dec 22 '22 00:12

Mikael Koskinen