Understanding Solutions


In Visual Studio 2005, a solution is a thin wrapper that contains a project or a number of projects. In earlier versions of Visual Studio, every project was part of a solution by default. In Visual Studio 2005, some project types can create a temporary solution for you. The solution concept is important because much of what you can do in Visual Studio 2005 revolves around accessing functionality that's exposed in different projects.

Solution Items and Miscellaneous Files

Solutions can contain solution items and miscellaneous files in addition to projects. Solutions can also contain Solution Folders, which allow you to group related projects. Solution items can consist of HTML files, bitmaps, icons, XML files, templates, schemas, and others. Miscellaneous files can be a bit of a mystery. First of all, you need to make the Miscellaneous Files folder visible in Solution Explorer to take advantage of these kinds of files. To see this folder, select the Show Miscellaneous Files In Solution Explorer check box on the Documents page in the Environment folder of the Options dialog box, as shown in Figure 2-2. Keep in mind that you won't see the Miscellaneous Files folder until you open a non-project item in the IDE by using File.OpenFile.

image from book
Figure 2-2: You can enable the Miscellaneous Files folder in the Options dialog box.

Miscellaneous files are files that you might open in the IDE for reference purposes—for example, if you want to review some code in a listing that you don't want to make part of your project. Opening such a file in the IDE without importing it into your solution automatically places the file into the Miscellaneous Files folder. The linked file is aggregated into the Miscellaneous Files folder in a solution.

Keep in mind that any file you open from Visual Studio 2005 gets a link in the Miscellaneous Files folder. This folder persists your items between sessions if you set Miscellaneous Files Project Saves Last to five items or so. This means that you can open specifications, schedules, and notes and have those files at your fingertips every time you open your project, as shown in Figure 2-3.

image from book
Figure 2-3: You can use the Miscellaneous Files folder to store links to documents that relate to your projects.

Solution Properties

The Solution Property Pages dialog box gives you easy access to the settings that apply to an entire solution. Among the options that you can control are the startup project or projects for your solution, the locations for files and symbols used for debugging, and the configuration settings that apply to the different projects in your solution.

To get to the Solution Property Pages dialog box, make sure that the solution name is selected in Solution Explorer, press Ctrl+Alt+A, and type Project.Properties in the Command Window. Another way is to right-click the solution and choose Properties. Most of the major programming projects in Visual Studio 2005 present you with the Property Pages dialog box, shown in Figure 2-4.

image from book
Figure 2-4: The Solution Property Pages dialog box gives you access to the settings

Common Properties

Clicking the Common Properties folder in the folder pane on the left exposes a number of options. The first option is Startup Project. In multiple-project solutions, you can select the project that launches when the solution is run from the Debug menu. You'll most often set this option on the fly by right-clicking a project name in Solution Explorer and then choosing Set As StartUp Project from the project shortcut menu.

If you want to run more than one project when you choose Start or Start Without Debugging from the Debug menu, select the Multiple Startup Projects option. Selecting this option lets you select the behavior of each of the projects in your solution when you invoke Debug.Start or Debug.StartWithoutDebugging. You can select Start, Start Without Debugging, or None. You can use the Move Up and Move Down buttons to the right of the list of projects to set the order in which the programs are started.

In a number of cases, running multiple projects concurrently might be useful. You might want to test some interprocess communication features between various assemblies in your solution. You might use a second project to do some profiling or instrumentation. Another use might be to run a utility that takes control of another assembly for automated testing purposes.

The second option in the Common Properties folder is Project Dependencies. When some assemblies in a solution depend on others in the same solution, the build order for the different projects in the solution is critical. The Project Dependencies settings let you specify which projects need to be built before others to get the entire solution up and running.

The last option in the Common Properties folder lets you set file paths for source files and debug symbols that might come up in your application. These settings allow you to step into the source code for libraries that are referenced by your projects but aren't part of your project. If you're debugging a project that's referencing a debug version of a .NET assembly, Visual Studio 2005 is usually able to find the source for the assembly if it's available. If the source is stored in a different location, you can specify the location of the source files and the debug symbols so that you can debug into that source.

Configuration Properties

Solutions can have multiple configurations that give you quick access to preset options that are related to your solution. The Debug and Release configurations are available to new projects by default, but you can create your own configurations by using Configuration Manager, which is accessible from the Solution Property Pages dialog box or from the Build menu (Build.ConfigurationManager).

Visual Studio 2005 offers two types of configurations: solution configurations and project configurations. Solution configurations are for configuring different build setups within a particular solution. For example, you can create and save a specific solution that allows you to select a different configuration for each project in your solution.

The second type of configuration is the project configuration. We'll discuss custom project configurations in detail later in the chapter, but for now, consider how different projects might relate to one another in a solution. Project configurations let you change some very specific build characteristics. These characteristics include code optimizations, debugging switches, and even the location of the project's compiled files. If you have five projects with different custom settings in a single solution, you should use custom solution configurations to save and manage different build options for your assemblies.

Solution and Solution User Options Files

The solution source .sln file is a plain-text document that describes the solution. The solution file contains links to the projects contained in the solution. It also contains version information about the format of the solution file itself.

image from book

Important Once you convert a file to Visual Studio 2005, you can no longer open it in earlier versions of Visual Studio.

image from book

The .sln file also contains information on the various configurations that have been set up in the solution. Information about the different solution configurations is stored in this file, along with information about how the different project configurations are organized in those solution configurations.

If you take a look at an .sln file in which solution items have been enabled and added, you'll notice that there's no information about these files. Solution items are considered user items, so links to these files are stored in the solution user options (.suo) file. If you pass a folder containing an .sln and an .suo file to another user on another machine, much of the information in the .suo file will become useless to the second user and will be ignored.

Some important items are stored in the .suo file that you can share with another person. Breakpoints that you set in your solution are stored in the .suo file, as are tasks that have been added to the Task List window. If you want to share that information with the person you're sharing the solution with, you should be sure to keep the .suo file in the same folder as the .sln file. If you don't need to share such information, we recommend deleting the .suo file because that file can contain personal and confidential data such as the paths to network shares and even your e-mail alias.




Working with Microsoft Visual Studio 2005
Working with Microsoft Visual Studio 2005
ISBN: 0735623155
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net