Migrating Source Code to Team Foundation Server from Visual Source Safe

Today, I delivered a session for myVSTS user group at Microsoft auditorium at KLCC. One of the attendees asked me on the way to migrate source code from Visual SourceSafe to Team Foundation Server. I’ll blog on the summary of steps needed for such a migration.

Summary Overview of Steps

Step 1 – Back Up Your VSS Database
Step 2 – Analyze Your VSS Database to Resolve Data Integrity Issues
Step 3 – Analyze Your Projects in VSS
Step 4 – Prepare to Migrate Your Projects
Step 5 – Migrate Your Projects

Step 1 – Back Up Your VSS Database

Prior to performing a migration, start by creating a backup copy of the VSS database you want to migrate.

   1. Ask all users to check in their files and then log off the VSS database. Ask the users to close both the Visual Studio Integrated Development Environment (IDE) and VSS Explorer.
      Important: Checked-out files are not migrated to TFS.
   2. Check that no one is currently logged into the database.
   3. Make sure that no analyze jobs are scheduled to run against the database.
   4. Copy the following folders (located beneath your VSS install directory) to your backup location:
       \DATA
      \Temp
      \USERS
   5. Copy the following files to your backup location:
      User.txt
      Srcsafe.ini
      By default, you can find these files in the following folder: \Program Files\Microsoft Visual Studio\VSS

Step 2 – Analyze Your VSS Database to Resolve Data Integrity Issues

In this step, you use the Visual SourceSafe Analyze utility to locate and fix data integrity issues in the database.

   1. Open a Command prompt and run Analyze.exe to search for database corruption or database errors. Use the following command:

           analyze "<sourcesafe data directory>"
          
      Use the -I option for unattended execution. This command reports potential problems.

   2. If there are permissions problems, "unable to checkout files" errors, "losing checkout status" errors, or any other errors that refer to the Status.dat file or to the Rights.dat file, run the Ddconv.exe program or the Ddconvw.exe program. These programs update a VSS database from an older format to the current format. By default, these programs are installed in the \Admin subdirectory.

Step 3 – Analyze Your Projects in VSS

In this step, you determine which projects you want to migrate and then run the TFS command-line tool VSSConverter.exe to analyze the VSS database for any potential issues that might cause migration problems.

   1. Create an Extensible Markup Language (XML) settings file (named for example, ConversionSettings.xml) as follows:

           <?xml version="1.0" encoding="utf-8"?>
            <SourceControlConverter>
               <ConverterSpecificSetting>
                 <Source name="VSS">
                       <VSSDatabase name="c:\VSSDatabase">
                       </VSSDatabase>
                 </Source>
                 <ProjectMap>
                   <Project Source="$/MyFirstProject"></Project>
                   <Project Source="$/MySecondProject"></Project>
                 </ProjectMap>
               </ConverterSpecificSetting>
            </SourceControlConverter>
          

      In the above example, MyFirstProject and MySecondProject represent the names of the project folders in VSS that you want to migrate. To migrate an entire VSS database, use <Project Source="$/"></Project>.
   2. Run VSSConverter.exe passing in the Analyze switch, from a Visual Studio command prompt to analyze your projects:

      VSSConverter Analyze ConversionSettings.xml

      When prompted, enter the Visual SourceSafe administrator password.

   3. Examine the output report and identify any conversion errors. The conversion tool creates an output report named VSSAnalysisReport.xml.
   4. Map VSS users to TFS users. The VSSConverter tool creates a UserMap.xml file that contains a list of all VSS users who performed at least one operation on the VSS database. Edit the UserMap.xml file and add your associated TFS usernames (Windows accounts). You must specify user names including the domain (MyDomain\MyUserName). The following example shows a Usermap.xml files that contains the VSS user accounts in the From attribute and the associated TFS usernames in the To attribute.

<?xml version="1.0" encoding="utf-8" ?>
<UserMappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <!–
    This file is automatically created by VSS Converter. You can optionally use the file to map
    a VSS user to a Team Foundation user. For example, <UserMap From="Jane" To="MyDomain\Janep"></UserMap>
    This mapping causes all actions logged by VSS user “Jane” to be changed to Team
    Foundation user “MyDomain\Janep” during migration.
  –>
  <UserMap From="ADMIN" To="Contoso\Administrator" />
  <UserMap From="Dave" To="Contoso\DaveM" />
  <UserMap From="Chris" To="Contoso\ChrisP" />
  <UserMap From="John" To="Contoso\JohnR" />
</UserMappings>

Step 4 – Prepare to Migrate Your Projects

In this step, you use the VSSConverter.exe tool to migrate your VSS projects.

   1. Modify the ConversionSettings.xml file created in Step 3 adding a new <Settings> element containing a <TeamFoundationServer> element as shown here:

          <SourceControlConverter>
             <ConverterSpecificSetting>
             …
             </ConverterSpecificSetting>
             <Settings>
               <TeamFoundationServer name="YourTFSServerName" 
                                  port="PortNumber"
                                  protocol="http">
               </TeamFoundationServer>
                  </Settings>
          ….
          </SourceControlConverter>
         
      Add the <Settings> element directly after </ConverterSpecificSettings> as a child element of <SourceControlConverter>.
   2. Modify the ConversionSettings.xml file you created adding Destination attributes to the <Project> elements as shown below. Set the value of the Destination attributes to the folder location in your TFS Team project to which you want to migrate your files.

<?xml version="1.0" encoding="utf-8"?>
 <SourceControlConverter>
   <ConverterSpecificSetting>
      <Source name="VSS">
          <VSSDatabase name="c:\VSSDatabase">
          </VSSDatabase>
      </Source>
      <ProjectMap>
        <Project Source="$/MyFirstProject"
                 Destination="$/MyTeam_ProjectOne">
        </Project>
        <Project Source="$/MySecondProject" 
                 Destination="$/MyTeam_ProjectTwo">
        </Project>
      </ProjectMap>
   </ConverterSpecificSetting>
   <Settings>
     <TeamFoundationServer name="YourTFSServerName"
                           port="PortNumber"
                           protocol="http">
     </TeamFoundationServer>
   </Settings>
 </SourceControlConverter>

In the <ProjectMap> section, for each VSS folder that you are migrating, replace MyFirstProject with the source VSS folders and replace MyTeam_ProjectOne with the destination folders in TFS source control. Include a <Project> entry for all the folders that you want to migrate.

Step 5 – Migrate Your Projects

Copy your VSS database to a local folder such as C:\VSSDatabases on the computer on which you want to run analysis and migration. Although you can migrate a VSS database to a shared folder on a remote computer, the migration takes much longer to finish.

   1. At the command prompt, type the following.

      VSSConverter Migrate Conversionsettings.xml

   2. Enter Y to confirm the migration. When prompted, enter the password for the Visual SourceSafe admin user.

Additional Considerations

If you used, sharing, branching or pinning in VSS you should be aware of the following issues.

    * Sharing. Team Foundation Server does not support sharing of files. Shared files are migrated by copying the version of the file at the time sharing began to a destination folder. Any subsequent changes made to the shared file are replicated to both the shared and the original copies.
    * Branching. Because branching in VSS uses sharing, the migration of a branched file results in the file being copied to the destination folder in TFS source control. After the branch event, the changes to any branch are migrated to the respective copy in TFS source control.
    * Pinning. Team Foundation Server does not support pinning. To help you locate items in Team Foundation source control that were once pinned in the VSS database, the VSSConverter tool labels any file that was pinned with the “PINNED” label.

Advertisements

One Response to Migrating Source Code to Team Foundation Server from Visual Source Safe

  1. encartyceaw says:

    hi, good site very much appreciatted

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: