24
|
Chapter 1, Master Projects and Solutions
#4 Hack the Project and Solution Files
HACK
Visual Studio 2005 includes an additional section that is not present in any
of the older versions of Visual Studio; it’s shown here:
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
If the FALSE is switched to TRUE, then the solution node is hidden in the
IDE.
Project Files
Each project creates a number of files to store information about itself. This
includes a project file and a user settings file. The extension for the project
file is based on the language type; for example, a C# Project is saved with
the extension .csproj and a VB.NET Project is stored with the extension .
vbproj. Thankfully, the internal formats of these various files are based on
the same XML schema. The beginning of each project file includes some
basic information about the project, including the version of Visual Studio
that it was created for as well as the GUID for this project. Here is an exam-
ple of this section:
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{89EE0E8E-C5C6-4772-A5EE-D347E40FB0E4}"
>
This is from a Visual Studio .NET 2003 project file, which is why the
ProductVersion is set to 7.1 and the SchemaVersion is set to 2.0. In Visual Stu-
dio .NET 2002, the
ProductVersion would be 7.0 and the SchemaVersion
would be 1.0. These settings are no longer relevant in Visual Studio 2005 as
project files are now MSBuild files.
Notice that the version number used for Visual Studio .NET
2003 is 7.1 in the project file and 8.0 in the Solution file.
The next section of the project file is the Build section, which includes build
settings and configuration settings as well as references information. Here is
the
Build settings section:
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
Hack the Project and Solution Files #4
Chapter 1, Master Projects and Solutions
|
25
HACK
AssemblyName = "HacksLib"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "HacksLib"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = "">
As you can see, this section includes information like the AssemblyName and
OutputType of the project. The next part of the Build section is for the vari-
ous build configurations:
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"/>
This section includes configuration-specific build settings. The project file
will usually contain at least a
Debug and Release section. The next part of the
Build section contains all of the references for this project. Here is an abbre-
viated example of this section:
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\
Framework\v1.1.4322\System.dll"
</References></Build>
The References section contains a reference tag for each assembly refer-
enced by the project. Starting with Visual Studio 2005, you can create a ref-
erence to either an assembly or an executable, which comes in very handy

Get Visual Studio Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.