For solutions, projects, folders, and files, properties can be defined that are used by the project system in the build process. These property values can be viewed and modified by using the Properties window in conjunction with the Project Explorer. As you select items in the Project Explorer, the Properties window will list the set of relevant properties.
Some properties are only applicable to a given item type. For example, linker properties are only applicable to a project that builds an executable file. However, other properties can be applied either at the file, project, or solution project node. For example, a compiler property can be applied to a solution, project, or individual file. By setting a property at the solution level, you enable all files of the solution to use that property's value.
A unique property has one value. When a build is done, the value of a unique property is the first one defined in the project hierarchy. For example, the Treat Warnings As Errors property could be set to Yes at the solution level, which would then be applicable to every file in the solution that is compiled, assembled, and linked. You can then selectively define property values for other project items. For example, a particular source file may have warnings you decide are allowable, so you set the Treat Warnings As Errors to No for that particular file.
Note that, when the Properties window displays a project property, it will be shown in bold if it has been defined for unique properties. The inherited or default value will be shown if it hasn't been defined.
solution — Treat Warnings As Errors = Yes project1 — Treat Warnings As Errors = Yes file1 — Treat Warnings As Errors = Yes file2 — Treat Warnings As Errors = No project2 — Treat Warnings As Errors = No file1 — Treat Warnings As Errors = No file2 — Treat Warnings As Errors = Yes
In the above example, the files will be compiled with these values for Treat Warnings As Errors:
project1/file1 | Yes |
project1/file2 | No |
project2/file1 | No |
project2/file2 | Yes |
An aggregating property collects all the values defined for it in the project hierarchy. For example, when a C file is compiled, the Preprocessor Definitions property will take all the values defined at the file, project, and solution levels. Note that the Properties window will not show the inherited values of an aggregating property.
solution — Preprocessor Definitions = SolutionDef project1 — Preprocessor Definitions = file1 — Preprocessor Definitions = file2 — Preprocessor Definitions = File1Def project2 — Preprocessor Definitions = ProjectDef file1 — Preprocessor Definitions = file2 — Preprocessor Definitions = File2Def
In the above example, the files will be compiled with these preprocessor definitions:
project1/file1 | SolutionDef |
project1/file2 | SolutionDef, File1Def |
project2/file1 | SolutionDef, ProjectDef |
project2/file2 | SolutionDef, ProjectDef, File2Def |