How to perform common tasks in Visual SourceSafe (317342)



The information in this article applies to:

  • Microsoft Visual C# 2005, Express Edition
  • Microsoft Visual C# .NET (2002), when used with:
    • Microsoft Visual SourceSafe 6.0c

This article was previously published under Q317342

SUMMARY

This step-by-step article shows you how to add a new project to Visual SourceSafe, how to check in and check out files, and how to compare differences between different versions of the same file.

back to the top

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
  • Microsoft Visual Studio .NET or Microsoft Visual Studio 2005
  • Registered Visual SourceSafe account
This article assumes that you are familiar with the following topics:
  • Visual C#
  • Windows Forms
  • Microsoft Visual Studio .NET or Microsoft Visual Studio 2005
back to the top

Visual SourceSafe common tasks

The following steps will demonstrate how to perform several common tasks in Visual SourceSafe.:

Add a solution to Visual SourceSafe

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialogue box, click Visual C# Projects under Project Types in the left pane, and then click Windows Applications under Templates in the right pane. By default, Visual Studio .NET creates a solution with three files named App.ico, AssemblyInfo.cs, and Form1.cs.

    Note In Visual Studio 2005, click Visual C# under Project Types.
  4. On the File menu, click Save All.
  5. On the File menu, point to Source Control, and then click Add Solution to Source Control. The Add to Source Safe dialog box appears.

    Note The Visual SourceSafe Login dialog box may appear. Type your user name, password, and database, and then click OK. If you are unsure of this information, consult your Visual SourceSafe Administrator.
  6. In the Name text box, type VSS Test Project, and then click OK.
  7. A confirmation dialog box appears and asks you if you would like to create a new project named VSS Test Project. Click Yes.
  8. Start Visual SourceSafe. Notice that a project named VSS Test Project appears under the root folder ($/).
back to the top

Check out a file under source control

  1. Locate Form1.cs in Solution Explorer. Notice that a blue lock icon appears next to the file. This indicates that your copy of this file is read-only.
  2. In Solution Explorer, right-click Form1.cs, and then click Check Out. The Check Out dialog box appears.
  3. In the Comments text box, type Check out file for the first time.
  4. Click Check Out. Notice that the lock icon has changed to a check mark in Solution Explorer.
  5. Change the Text property of Form1.cs to VSS Test Form.
  6. Click on the File menu, and then click Save All.
  7. Start Visual SourceSafe. Notice that Form1.cs and Form1.resx appear checked out under the VSS Test Project folder.
back to the top

Compare versions

  1. Right-click Form1.cs in Solution Explorer, and then click Compare Versions. The Difference Options dialog box appears.
  2. Click OK. The Differences For File dialog box appears. Both versions of this file are displayed side-by-side. Deleted lines appear in blue, changed lines appear in red, and new lines appear in green.
  3. Press ALT+F4 to close the window.
back to the top

Check in a file under source control

  1. Right click Form1.cs in Solution Explorer and then click Check In. The Check In dialog box appears.
  2. In the Comments text box, type Changed text to VSS Test Form.
  3. Click Check In. Notice that the icon has changed back to a blue lock in Solution Explorer.
  4. Start Visual SourceSafe. Notice that Form1.cs and Form1.resx no longer appear checked out under the VSS Test Project folder.
back to the top

Complete code listing

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication2
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			// 
			// Required for Windows Form Designer support
			// 
			InitializeComponent();

			// 
			// TODO: Add any constructor code after InitializeComponent call
			// 
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(292, 268);
			this.Name = "Form1";
			this.Text = "VSS Test Form";

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
	}
}
				
Note The code should be changed in Visual Studio 2005. By default, when you create a Windows Forms project, Visual C# adds one form to the project. The form is named Form1. The two files that represent the form are named the Form1.cs file and the Form1.designer.cs file. You write your code in the Form1.cs file. The Form1.designer.cs file is where the Windows Forms Designer writes the code that implements all the actions that you performed by dragging and dropping controls from the Toolbox. For more information about the Windows Forms Designer in Visual C# 2005, visit the following Microsoft Web site: back to the top

Troubleshooting

You need a Visual SourceSafe account to complete these tasks. If you do not have an account, consult your Visual SourceSafe Administrator.

back to the top

REFERENCES

For more information about how to use Visual Studio .NET in a team development environment, visit the following Microsoft Developer Network (MSDN) Web site: back to the top

Modification Type:MajorLast Reviewed:1/18/2006
Keywords:kbHOWTOmaster KB317342 kbAudDeveloper