Export (0) Print
Expand All

Visual Studio Web Project Source Control Overview

If you have a source code control system installed on your computer that is compatible with Visual Studio, you can use the source code control commands that are included with Visual Studio to check files in and out of source control, merge files, view file history, and accomplish other source code control tasks with your Web site. For example, if you have Microsoft Visual SourceSafe (VSS) installed, you can perform VSS tasks directly in Visual Studio. Other providers can integrate with Visual Studio if they follow Visual Studio Industry Partner (VSIP) standards.

The exact behavior of source code control in Visual Studio depends on what source code control system you are using. All VSIP-compliant source code control systems support the base commands that are required to perform check in, check out, and other tasks. The Visual Studio commands and user interface for these functions are the same no matter what source code control system you are using. However, for some functions, such as merging files, Visual Studio simply hosts the source code control provider's own user interface, which can vary from one provider to another.

Source code control commands in Visual Studio are automatically enabled if Visual Studio is configured to use a compatible source code control provider that is installed on your computer. You might need to enable source code control functionality in Visual Studio by clicking Tools, Options, Source Control, Plug-In Selection and selecting the correct source control plug-in.

Source code control works with file-system Web site projects, local IIS Web site projects, and Web application projects. For information about differences between Web site projects and Web application projects, see Web Application Projects versus Web Site Projects.

When you check out a file, a copy of the file is moved from the source code control repository to the location where you store the files for your project.

For remote Web site projects, you cannot use source control from within the Visual Studio environment. Remote Web site projects require FrontPage Server Extensions (FPSE) from Microsoft on the remote server, which provides limited support for source code control functionality. Therefore, to use source control with remote Web site projects, your Web site project must be configured to use the source control system on the server where the files are located.

FTP Web site projects do not support source control. In an FTP Web site project, all files are stored on a central server and are read and written using the FTP protocol, which does not support check-in and checkout functionality.

When you want to edit a file, you check the file out of the source control system. Checking out a file puts a read-write copy of it on your computer. When you are done editing, you check the file back into the source control system. To be able to check files out or in, you must be able to log into the source control system. For information about login credentials, contact your source code control administrator.

Visual Studio allows you to check files out explicitly or implicitly. For explicit checkout, you select the files to work with and issue an explicit command to check them out using the source control mechanism. For implicit checkout, you simply open a file in Visual Studio.

If the file has not been checked out, it is in read-only mode. When you make a change to the file, Visual Studio checks out the file so that you can save your changes. By default, Visual Studio does not prompt you before checking out the file. To enable prompts, click Tools, Options, Source Control, Environment, and then under Checked-in item behavior, select Prompt for check out in the list boxes beside On Save and On Edit. The default is Check out automatically.

You can configure Visual Studio not to perform implicit checkouts. Click Tools, Options, Source Control, Environment, and then under Checked-in item behavior, select Do nothing in the list boxes beside On Save and On Edit. In this case, files are opened in read-only mode. If you want to be able to save changes, you must first explicitly check out the file.

Most source code control systems allow multiple developers to check the same file out at the same time, which means that two or more developers might edit a file at the same time. Therefore, when you check in a file, the source code control system determines whether the file has been changed by someone else since you checked it out. If the file has not changed, it is checked in as usual. However, if the file has changed since you checked out your version, the source code control system attempts to merge your changes with the other changes it finds in the file.

The procedure used to perform the merge depends on what your source code control provider is. A typical scenario is as follows:

  1. You check in a file.

  2. The source code control system detects that the file has been changed by someone else since you last checked it out and merges your changes with the file in the repository.

  3. The source code control system displays a dialog box highlighting the two sets of changes.

  4. You accept or reject the changes. If you accept them, the file is checked in with the merged changes.

When you initially add a new file to the Web application, the file exists only locally on your computer. When source code control is enabled in Visual Studio, new files are marked with an icon in Solution Explorer indicating that the file is new. To add the file to the source code control repository, you can check it in individually. Alternatively, you can check in the file as part of the entire Web application, which will check in all checked-out files, including your new file.

While working with a Web site that is under source control, you might want to move, rename, or delete a file. It is recommended that you move, rename, or delete files using the source control mechanism while the files are checked in. The next time another developer checks out the changed file, Visual Studio applies the changes on their computer.

If you are a developer just joining a team and want to work with a Web project that is already under source control, you can retrieve a copy of the project from the repository. In source control terminology, this is sometimes referred to as synchronizing or enlisting. Synchronizing is also useful when setting up new computers or creating a backup of the files under source control.

Rather than creating a new Web project, you open the existing project from source control. After providing appropriate credentials (if required), you specify a location on your local computer. Visual Studio then puts read-only copies of the application's files in the specified location. From that point, you can work with the files, checking them out, editing them, and checking them back in.

If a project has already been put under source control, you open it from source control rather than opening it directly on your local computer.

If you are enlisting in an individual Web project for the first time, in Visual Studio, click File, Open Web Site, and click the Source Control tab to enter your credentials and select a local location for the site. After you have enlisted in a project, Visual Studio works with the source control mechanism when you edit files. Enlisting stores the binding information in the local Visual Studio cache, indexed by the project name.

Community Additions

© 2014 Microsoft