Hack 5. Remove SourceSafe Bindings

Visual SourceSafe comes bundled with Visual
Studio for free, so it is one of the most popular source code control
programs for Visual Studio developers. However, it will leave cruft
in your source tree that you might want to get rid of if you send
your code elsewhere.In order to do its job, SourceSafe adds some XML elements to the
Visual Studio solution and project files and adds some source control
files to each project directory. These changes are transparent when
using SourceSafe, but cause problems when sharing the solution with
someone who does not use SourceSafe or someone who does not have
access to your SourceSafe database. It could also cause problems if
you are attempting to change your source code control provider from
SourceSafe to something else, like CVS or Subversion.
1.6.1. Removing Bindings
You must change two things to remove all
SourceSafe bindings. The solution file and all project files must
have any source control information removed, and any files ending in
.scc must be deleted. To do this, the Visual
Studio solution and project files must not be in use, so close down
the Visual Studio IDE.
|
.sln. Right-click on a solution file, select the
Open With... option, then choose Notepad to open the file for
modification. Examining the solution file for a sample Visual Studio
application called SourceSafeBindingRemover yields
this code:
Microsoft Visual Studio Solution File, Format Version 8.00The first line is the solution file version declaration. The first
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"SourceSafeBindingRemover",
"SourceSafeBindingRemover\SourceSafeBindingRemover.csproj",
"{C7687560-4B36-47E3-AF33-748E76411259}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 2
SccLocalPath0 = .
CanCheckoutShared = false
SolutionUniqueID = {634C866F-3CEB-43A1-9C7F-D34A03F0A044}
SccProjectUniqueName1 =
SourceSafeBindingRemover\\SourceSafeBindingRemover.csproj
SccLocalPath1 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection1 =
SourceSafeBindingRemover\EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{C7687560-4B36-47E3-AF33-748E76411259}.Debug.ActiveCfg
= Debug|.NET
{C7687560-4B36-47E3-AF33-748E76411259}.Debug.Build.0
= Debug|.NET
{C7687560-4B36-47E3-AF33-748E76411259}.Release.ActiveCfg
= Release|.NET
{C7687560-4B36-47E3-AF33-748E76411259}.Release.Build.0
= Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
element is the Project section that begins on the
second line and continues to the EndProject line.
The second element is the Global section. The
Global section contains things such as the active
solution configuration and source control, and inside it are
individual GlobalSections that contain the various
settings. The GlobalSection(SourceCodeControl)
contains the SourceSafe bindings. To remove the SourceSafe bindings
from the solution file, remove the entire section from the line with
GlobalSection(SourceCodeControl) until the first
EndGlobalSection. Save the solution file before
closing Notepad. Each project file needs to be modified in a
similar manner, but the project files are easier to modify. Using
Notepad to look at a sample project file shows this format:
<VisualStudioProject>The lines that need to be deleted are all within the
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{C7687560-4B36-47E3-AF33-748E76411259}"
SccProjectName = "SAK"
SccLocalPath = "SAK"
SccAuxPath = "SAK"
SccProvider = "SAK"
>
<Build>
<Settings
ApplicationIcon = "App.ico"
AssemblyKeyContainerName = "
AssemblyName = "SourceSafeBindingRemover"
AssemblyOriginatorKeyFile = "
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "WinExe"
PreBuildEvent = "
PostBuildEvent = "
RootNamespace = "SourceSafeBindingRemover"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = "
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = "
DefineConstants = "DEBUG;TRACE"
DocumentationFile = "
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = "
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
... sections deleted
</CSHARP>
</VisualStudioProject>
<CSHARP> XML tag. If it is a VB project, the
tag will be VisualBasic instead. Delete all lines
that begin with SCC within the opening
CSHARP or VisualBasic XML tag.
In the preceding sample file, the four lines starting with
SccProjectName, SccLocalPath,
SccAuxPath, and SccProvider
would all need to be deleted. Save the file and close Notepad. You
will need to do this for each project file in your application.With Visual Studio 2005, the project file is a completely different
format (it is now based on MSBuild), but the data you will need
to delete is very similar. Here is the relevant section of the
project file:
<PropertyGroup>In this example, the elements named
<Configuration Condition=" '$(Configuration)' = = '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' = = '' ">AnyCPU</Platform>
<ProductVersion>8.0.40903</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{951EBC65-CA21-4C24-B501-DFF2A03A03F1}</ProjectGuid>
<OutputType>Library</OutputType>
<StartupObject>
</StartupObject>
<AssemblyName>SourceSafeBindingRemover</AssemblyName>
<RootNamespace>SourceSafeBindingRemover</RootNamespace>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
SccProjectName, SccLocalPath,
SccAuxPath, and SccProvider
would all need to be deleted.The last thing to do is remove all the files that SourceSafe creates
with the .scc extension. Every directory will
contain a file called vssver.scc. Folders with
project files will have an associated
mssccprj.scc file. There are also files ending
with <Project Name>.csproj.vspscc
(vbproj if it is a Visual Basic Project) or
<Solution Name>.etp.vspscc. All of these
files should be deleted, and with that, your application will have
all the SourceSafe bindings removed.
1.6.2. Hacking the Hack
I have written a simple Windows application that automates
the removal of SourceSafe bindings using the previous steps. You can
download the latest version from http://workspaces.gotdotnet.com/SourceSafeBindingRemover.You can see this application in Figure 1-16.
Figure 1-16. SourceSafe Binding Remover

Folder button and click the Remove SourceSafe Bindings button. If the
Remove Bindings? checkbox is unchecked, then the window will show you
a preview of all the files that will be deleted. This will help you
make sure that none of your source code files are accidentally
included in the delete list. If the checkbox is checked, clicking the
Remove SourceSafe Bindings button will remove all SourceSafe bindings
from the selected root folder and any subfolder, recursively.Currently this tool works only for Visual Studio .NET
2002 and Visual Studio .NET 2003. Darrell Norton