From Seapine Labs
Visual Studio 2005 Integration
[edit] Background
This example uses a solution that contains one project that is not associated with a source code control application and has not been added to Surround SCM. The solution only contains this one C# project.
Figure 1 shows the solution and project in the Visual Studio 2005 solution explorer.
Figure 1: Solution Explorer
As shown in Figure 2, the project is saved in the \WorkDir\VS05INTExample\ folder.
Figure 2: Project Location
The D:\WorkDir\ directory is a folder that is the root for all the working directories for this computer. It is not a working directory for a repository, as shown in Figure 3.
Figure 3: Working Directories
[edit] Adding an Existing Solution to Surround SCM
The solution and project have to be added to Surround SCM before source control commands can be accessed. When you put a solution under source control you are prompted to automatically add all projects and files.
To add the solution to Surround SCM, open the Visual Studio solution and choose File > Source Control > Add Solution to Source Control.
Surround SCM cannot establish an association because the solution has not been added to Surround SCM and the directory where the solution resides is not set as a working directory in Surround SCM. You are prompted to establish this association, as shown in Figure 4.
Figure 4: Fix Association Message
To establish an association between the solution and Surround SCM, click the Fix button to create a repository for the project.
The Repository Browser dialog box opens after you click the Fix button.
Figure 5: Surround SCM Repository Browser
Select the branch and repository you want to create the new repository in. In this example, shown in Figure 6, the repository for the project will be created on the mainline branch under the top-level repository. Click the Create Repository button after the branch and repository are selected.
Figure 6: Create Repository Dialog Box
Surround SCM creates a single repository if the solution and the project files reside on the same directory. If they reside in different directories, Surround SCM creates a repository for each folder. In this example, Surround SCM creates a sub-repository because the project files reside in a directory.
As the Figure 7 illustrates, the repository structure follows the same directory structure shown in Figure 2. Note that the bin and obj repositories are not created in Surround SCM because the files these directories contain are not supposed to be controlled.
Figure 7: Repository Structure
[edit] Accessing Surround SCM Commands in Visual Studio
[edit] Getting the latest file version
You can automatically get the latest revision of selected files.
In the Solution Explorer, select the files you want to get. Choose File > Source Control > Get Latest Version. The latest version of all solution and project files are retrieved to the working directory.
Getting files
Get files when you want to view a file but do not need to make any changes.
In the Solution Explorer, select the files you want to get. Choose File > Source Control > Get. The Get dialog box opens.
To get an item, select the corresponding check box. If you do not want to get an item, clear the check box.
Click the Options button to access advanced get options.
Figure 8: Get Dialog in Visual Studio
Surround SCM includes the following advanced get options:
- Force file retrieval from the server: Forces a get of the server copy of the files regardless of the file in the working directory.
- Make files writable: Retrieves a writable copy of the file.
- Merge should first attempt auto-merge: If a merge is needed, and this option is selected, Surround SCM will first try to auto-merge the files. If this option is not selected, you may be prompted to manually merge the files. This situation usually only occurs with non-exclusive check outs when another user checks in changes at the same time.
- Overwrite option: Specifies what happens if a modified file is found.
- File timestamp: Specifies the timestamp to be placed on the file retrieved.
- Get Based on Options: These options are used to specify which version of the file is retrieved. You can get a file based on the version, timestamp, label, or workflow state.
Figure 9: Surround SCM Get Options
[edit] Checking out files
Check out files when they need to be modified. To check out, select the file then choose File > Source Control > Check Out for Edit.
Figure 10: Check Out Dialog Box
Click the Options button to access the following advanced check out options:
(Note: The recursive check box is unavailable because it does not apply to check outs from the Visual Studio IDE.)
- Exclusive check out: Prevents other users from checking out the files.
- Force file retrieval from the server: Forces a get of the server copy of the files regardless of the file in the working directory.
- Check in as part of the following changelists: Attaches the files to a changelist when they are checked in.
- View pending changelist after check out: Displays the pending changelists after the check out.
- Overwrite option: Specifies what happens if a modified file is found.
- File timestamp: Specifies the timestamp to be used when the files are checked out from the server.
Figure 11: Advanced Check Out Dialog Box
[edit] Undoing check out
If a file is checked out and modified, but then a decision is made to not save the changes, the check out can be undone.
To undo a check out, select the file then choose File > Source Control > Undo Check Out.
Figure 12: Undo Check Out Dialog box
Like the other dialog boxes discussed in this article, the undo checkout dialog box includes advanced options.
Figure 13: Advanced Undo Check Out Options
- Get original version: Retrieves a read-only copy of the version of the file when it was checked out.
- Get latest version: Retrieves a read-only copy of the latest version of the file. This will be different from the original version if the file was modified by another user while it was checked out (i.e., was not an exclusive check out).
- Leave local file: Leaves the local file as is.
[edit] Checking in files
Changes that are made to files need to be checked in to the Surround SCM Server periodically. Simply saving the files does not automatically check in the files. Checking in the files creates a new version of the files and gives other users access to the changes.
To check in files from the Visual Studio IDE, select the files then choose File > Source Control > Check In.
Figure 13: Check In Files Dialog Box
Click the Options button to access the following advanced check in options:
- Prompt for Seapine Suite Integration: Displays a list of defects based on the TestTrack integration set up for the repository where the project resides in Surround SCM. This allows you to link the file with a TestTrack Pro defect.
- Check in as part of a changelist: Attaches the file to a new or existing changelist.
- View pending changelists after check in: Displays the pending changelists after the check in. The changelist can be reviewed, edited, and committed.
- Apply comments to all: Applies the same comment to all files being checked in. Only applies when checking in more than one file at a time.
- Change state when version updated: Change the state of the file in Surround SCM if the workflow is enabled for the repository where this file resides.
- Get file after check in: Retrieve a read only copy of the file after it is checked in.
- Keep checked out: Checks in the changes but eaves the file checked out and writable. This option is best used when applying periodic check ins as long series of changes are made. This can help avoid a catastrophic loss of work if the hard drive of the local computer crashes and the local file cannot be retrieved.
- Leave local copy as is: Leaves a writable copy of the file in the working directory.
- Remove local copy: Removes the file from the local directory.
- Label: Labels provide a way to mark a specific version of a file or repository.
- Skip server auto-merge: Checks in the file without merging it. The file becomes the new version even if another user made changes and checked in the file after the file was checked out.
- Update version even if no change is made: Allows files that were not modified to be checked in. The version number increments by one.
- Make files writable: Leaves the copy of the file in the working directory writable.
Figure 15: Advanced Check In Options
[edit] Refreshing file status
You can query the server to get the latest status of each file. For example, if you check out a file from Surround SCM it will not be marked as checked out in Visual Studio until you refresh the status.
In the Solution Explorer, select the files you want to refresh then choose File > Source Control > Refresh Status.
[edit] Comparing file versions
You can compare the local copy of a file with the latest revision in Surround SCM.
In the Solution Explorer, select the file you want to compare then choose File > Source Control > Compare Versions.
The differences utility starts if differences are found between the two file versions. For additional
information about the utility refer to the application’s documentation.
[edit] Viewing file history
File history provides a way to view a source file’s history and work with a historical file version.
To view the history, select the file in the Solution Explorer then choose File > Source Control > History.
[edit] Viewing file properties
File properties include general and check out information.
To view properties, select the file in the Solution Explorer then choose File > Source Control > Surround SCM Properties.
- The General tab includes read-only information about the file. Depending on your security permissions you may also be able to Expand keywords or select a File type.
- The Check Out tab includes read-only check out information about the file.
- The Shared tab, which is only available if the file is shared in Surround SCM, displays the name of the mainline branch and repository/subrepository the file is shared with.
[edit] Excluding files from source control
Files can be excluded from source control. Keep in mind that excluded files can no longer be checked in and out.
To exclude a file, select the file in the Solution Explorer then choose File > Source Control > Exclude from Source Control. The Check Out for Edit dialog box opens because this command affects the parent project or solution.
The selected file is excluded from source control. The file icon in the Solution Explorer changes to a red circle with a minus sign.
Note: Click Advanced if you want to destroy the file and remove it from Surround SCM. When a file is destroyed, any record of its existence is also deleted.
[edit] Setting source control options
You can configure various source control options such as default check in options. Refer to the Visual Studio documentation for more information about the options you can set.
To set source control options, choose Tools > Options.
Figure 16: Visual Studio Options
Expand the Source Control category then select Environment to set the following options:
- Use...settings: Specifies the role you want to use.
- Get everything when a solution is opened: Automatically retrieves the latest revision of each file when a solution is opened. May be slow for large projects.
- Check in everything when closing a solution: Automatically checks in all files when a solution is closed. May be slow if you have a large number of files checked out.
- Display silent check out command in menus: Displays the Check Out Now command, which allows you to check out items without displaying the Check Out dialog box.
- Display silent check in command in menus: Displays the Check In Now command, which allows you to check in items without displaying the Check In dialog box.
- Keep items checked out when checking in: Checks in the changes but leaves the file checked out and writable.
- When checked in items are edited: Specifies what happens if you edit an item that is not checked out.
- Allow checked-in items to be edited: Specifies that checked in items can be edited. Editing checked in items can lead to data loss.
- When checked-in items are saved: Specifies what happens if you save an item that was not checked out.
Figure 17: Source Code Environment Options
Select the Plug-in Setting category to set provider-specific options.
- Use...settings: Specifies the role you want to use.
- Login ID: Specifies the Surround SCM username. This field is populated automatically.
Figure 18: Source Code Plug-in Options
[edit] Opening a project from source control
To open a project or solution, choose File > Source Control > Open from Source Control. Select the branch and repository that contain the project or solution you want to open in the Surround SCM Repository Browser.
[edit] Adding a project from source control
To open a project and add it to the solution choose File > Source Control > Add Project from Source Control. Select the branch and repository that contain the project you want to add in the Surround SCM Repository Browser.
[edit] Changing source control
You can change the branch and repository associated with a solution or project. You must first remove the source control association then select the new branch and repository.
To change the branch or repository choose File > Source Control > Change Source Control.
- Click Unbind to remove the solution/project from source control.
- Click Bind to associate the solution/project with a new branch and repository. This opens the Surround SCM Repository Browser. Select the branch and repository and click OK.
The solution/project is now associated with the selected branch and repository.
Note: Refer to the Visual Studio documentation for more information about managing source control connections and bindings.
Figure 19: Change Source Control Dialog Box
[edit] Troubleshooting Visual Studio and Surround SCM integration
The following information is provided to help you troubleshoot common issues.
[edit] Surround SCM is not displayed as an active SCM provider
If Surround SCM is not available from the Source Control menu it is not configured as the active SCM provider. Check the following for possible causes and resolutions.
- The Surround SCM plug-in is not installed.
- Run the Surround SCM client installation.
- Surround SCM is not configured as the active SCM provider.
- Open a registry editor utility such as regedit. Go to HKEY_LOCAL_MACHINE/SOFTWARE/SourceCodeControlProvider key. Note the value of the ProviderRegKey string. For example, Software\Seapine Software\Surround SCM\Scci.
- Go to HKEY_LOCAL_MACHINE/<value of ProviderRegKey string>.
- Verify the value of the SCCServerName is Surround SCM.
- Verify the value of the SCCServerPath is C:\Program Files\Seapine\Surround SCM\Surround SCM SCCI.dll for default installation. If you installed Surround SCM in another directory, make sure the correct path is entered.
[edit] Surround SCM files are not displayed correctly in Visual Studio
You added files to Surround SCM but the Surround SCM menu items are not enabled when the files are viewed from Visual Studio. Check the following for possible causes and resolutions.
- The Visual Studio project is configured incorrectly.
- Make sure the project points to a Surround SCM branch/repository that exists on the Surround SCM server you are connecting to. To check this information, open the project and solution files in Notepad and check the SCCProjectName value. The format is <branch>:<repository>. You can also use the Change Source Control command to check this information in Visual Studio.
- The branch/repository points to an invalid working directory.
- Make sure the working directory for the repository associated with the project points to the same local directory as the project. You may experience integration problems if you set up the working directory to point to a different location.
- The local .MySCMServerInfo file is out of sync.
- Visual Studio cannot determine where Surround SCM files are located if the .MySCMServerInfo file is out of sync. Go to the directory where the Surround SCM files are located and open the .MySCMServerInfo file with Notepad. Make sure it points to the correct branch/repository. If it does not, delete the file and refresh it from Visual Studio to regenerate it with the proper data.
- The files are above the solution in the local directory tree.
- Visual Studio does not support SCM integration with files that are not in or below the solution’s local directory tree. If the files are above the solution, create a new solution file at the top level of the source tree then add the projects to the new solution.
[edit] Files cannot be added to Surround SCM from Visual Studio
If files cannot be added to Surround SCM from Visual Studio, check the following for possible causes and resolutions.
- Check the Visual Studio Output window to view error messages.
- The Visual Studio Output window displays messages as Surround SCM actions are performed. Check this window for error messages that occur when you try to add files.
- The Visual Studio project is configured incorrectly.
- Make sure the project points to a Surround SCM branch/repository that exists on the Surround SCM Server you are connecting to. To check this information, open the project and solution files in Notepad and check the SCCProjectName value. The format is <branch>:<repository>.
- The Visual Studio project points to the wrong Surround SCM branch.
- This can occur if you maintain the Visual Studio project and solution files in Surround SCM then branch the repository that contains the files. After the repository is branched the local .MySCMServerInfo file still points to the old branch, which is where the files are being added. Configure Visual Studio to point to the correct branch then add the files to Surround SCM. Open the project and solution files in Notepad and change the SCCProjectName value to point to the correct branch. Then add the files to Surround SCM.