SCC Removal Tool for TFS / Visual Studio

Preface

Publishing sample code to the blog requires some manual tasks to remove all the source control configurations and files as well as the user specific files of Visual Studio.

After publishing a few code samples, having to do the same changes manually again and again, I thought it was time to create a tool doing this for me. Of course, taking the time I needed to build that tool, I could have published a few more code samples. But it is much more fun to write a tool than to do the same thing again and again 😉 And of course, having a tool makes sure I will not forget a step.

The primary intention is to disconnect the solution from source control. I don’t like samples downloaded from the internet where the first thing that happens is, that VS complains it cannot connect to the source control. Beside removing the SCC footprint, the tool also deletes all the output. I think the output is not needed when the source code is delivered.

This tool is created based on the usage of TFS 2012 und Visual Studio 2012. So maybe, when using older versions of VS or other version control systems, this tool might not remove all the SCC footprint.

SCC Files To Delete

TFS creates a .vssscc for each solution and a .vspscc file per project. The tool searches for these files in the working directory and its subdirectories and deletes them.

Disconnect From Source Control

The solution file .sln file contains some information about the source control system where the code is stored. All this is configured inside GlobalSection(TeamFoundationVersionControl). The whole section needs to be removed to disconnect the solution from source control.

The project file .csproj (suffix of C# projects) also contains some SCC footprint. Every line starting with >Scc needs to be removed too.

User Files To Delete

Visual Studio stores user-specific information related to the solution in .sou files. User-specific information related to the project are stored in .user files. The tool deletes all of these file types in the working directory and below.

Directories To Delete

By default, the output of a project is written to bin and obj directories, which are located below the project directory. All directories with these names are deleted. You can enter additional directory names in the “Remove Directories” field. I use this because I change the output for all configurations to “.\Output” by default.

And for those of you who create unit tests: the TestResults directories are included in the list of default directories too.

Configuration Abilities

The tool reads the default file types and directories to be deleted from the app.config. So in case you like to change these values, just edit the file. The tool also stores the values entered (working directory and additional directories to be removed) into the app.config.

The SCC footprint detection of the solution and project files is hard-coded. So in case you need some changes here, you have to change the code.

Maybe Incomplete

Yes, the tool might be not be complete. There are several reasons for this: C# is the preferred programming language in my company. So maybe some language-specific files or settings are not covered by the tool.

Also, we do create only a small subset of applications types, like WPF, Windows services, … So maybe SharePoint or Office projects look different. Again, if you need to cover these project types and the tool does not: you have the code, so change it.

Not To Be Forgotten

The software is provided “as is”, without warranty of any kind, expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

Be careful!

The source code can be found here.

SCC Remover Screenshot

Simple Migration of TFS 2012 Express to TFS 2012 Full Version

Starting to dig a little bit deeper into TFS 2012, I noticed that my local TFS 2012 Express installation had not all the features I saw on Team Foundation Services (tfs.visualstudio.com/), which I was using too. Of course, if I had read the docs, I might have known before that TFS 2012 Express is not a fully featured TFS – but I never have heard of real programmers who care about docs 😉

So I downloaded the TFS full version and started the installation, hoping it will notice the existing Express instance and start a migration wizard. Well, the installation noticed that there was an existing Express instance. But it did not start a migration wizard. Instead, it told me to uninstall TFS 2012 Express first.

Since I didn’t wanted to lose my existing projects and items, I created a backup of the Tfs_Configuration and the Tfs_DefaultCollection databases frist. Please notice that TFS 2012 Express requires these databases to be run by the SQL Server Express instance on your machine. Because I wanted to have the TFS full version to run on the SQL Server full instance, I restored these databases to that instance, saving the database files to a different location (just change the settings in the restore dialog of SQL Server Management Studio).

After having the databases restored, I uninstalled TFS 2012 Express and started the TFS 2012 Full Version installation. After a while, a tool opened up where I could choose the type of installation (can’t remember the tool’s name). Here, I selected “Application Tier only”. The wizard found both the port and database settings of the already uninstalled Express version. Fortunately, one can change the database setting. Just enter the name of the SQL Server instance TFS should use. If it is installed locally, do not enter “(local)”. TFS is not able to use this setting (will be checked during installation). After a few more clicks, where I did not changed any default value, the installation continued and completed successfully.

My Visual Studio connected to the TFS Full Version without changing any settings, and all items were present too. In case you miss some of the shiny features, maybe you need to adjust the access level.

Here is, in short words, what I have done to migrate the TFS 2012 Express installation to TFS 2012 Full on my local machine:

  • Created a full backup of my machine (aka a snapshot of the VM)
  • TFS used by one user only, no Domain infrastructure
  • SQL Server 2012 (full) already installed (local too)
  • Backup TFS databases from SQL Server Express and restore it to SQL Server 2012 with different file path
  • Uninstall TFS 2012 Express
  • Add Full Text Search to SQL Server 2012, if not already installed (required by TFS 2012)
  • Install TFS 2012 Full Version, select “Application Tier only” when installation comes to that point
  • Change the database to the one hosted by the SQL Server instance, do not use SQL Express
  • Install Build Server if you like to (or need it)
  • Adjust the access level, if required.
    If you like a full featured list, you might want to have a look at tfs2012visualguide.codeplex.com/. Or you might want to download the official installation guide from here: www.microsoft.com/en-us/download/details.aspx?id=29035.

  • Configure TFS Express 2012 To Use Existing SQL Server Instance


    Update 2013-01-09 <Start>
    One should not go this way. When I tried to install TFS Express Update 1, the update failed because it requires TFS Express to run on a SQL Express instance.
    So – in case you want to keep your installation up to date – do not use this hack!
    Update 2013-01-09 <End>

    When I installed TFS Express 2012, I was surprised that I could not choose the SQL Server instance to use during setup. Instead, the TFS Express installation put a SQL Express on my machine without asking. Even though a SQL 2012 instance was already installed 🙁

    Well, since I did not want to have two SQL Server instances running on my machine – what a waste of resources – I re-configured the TFS to run on the SQL 2012 instance. There were only a few steps to take after the successful TFS Express installation:

    – Detach the databases Tfs_Configuration and Tfs_DefaultCollection from the SQL Express instance. Maybe you have to kill some processes that are currently using these databases, using the activity monitor.

    – Copy the files of these two databases into your preferred database file directory.

    – Attach the copied(!) files to your primary SQL Server instance.

    – Re-attach the original files to the SQL Express instance.

    – Add the missing roles to the master database; compare the roles with SQL Express

    – Add the missing security settings (user mappings) of the NT Authority\Local Service for Tfs_Configuration and Tfs_DefaultCollection; compare the settings with SQL Express

    – Open the web.config located in Program Files\Microsoft Team Foundation Server 11.0\Application Tier\Web Services and change the connection string applicationDatabase in the appSettings section (no, it is not located inside of the connectionStrings section!).

    – Change the DisplayName to the name of your SQL Server instance (default: (local)) in the table tbl_CatalogResource of the Tfs_Configuration database, where the current value is SQLEXPRESS.

    – Reboot your machine.

    – Stop the SQL Express instance and change its start type to manual or disabled

    – Use the TFS Admin Console to check whether the changes were successful

    WARNING: This only works as long as you are do not need to create a new Team Project Collection. Creating a new collection in this scenario leads to an error telling that TFS Express requires a SQL Express (beside other errors telling that (local) is not a valid server name, which can be fixed easily). So as long as you are happy with a single collection (the DefaultCollection), this hack should work. Otherwise, you have to run the SQL Express instance beside your full featured SQL Server instance. Sad thing!