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.
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();
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With