[原创]自定义VS2010项目文件vcxproj动态管理inc lib
2011-12-15 20:02 Scott Guthrie Liu 阅读(934) 评论(0) 编辑 收藏
.vcxproj 是关键
A guide to .vcxproj and .props file structure
基本框架
.vcxproj基本框架
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
<ItemGroup Label="ProjectConfigurations" />
<PropertyGroup Label="Globals" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<PropertyGroup Label="Configuration" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" /></Project>
基本框架解释
基本框架解释
<!-- This is the root node. It specifies the MSBuild version to useand also the default target to be executed when this file is passedto MSBuild.exe -->
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
<!-- This contains the project configurations known to the project (such as Debug|Win32 and Release|Win32). -->
<ItemGroup Label="ProjectConfigurations" />
<!-- This contains project level settings such as ProjectGuid, RootNamespace, etc. These properties are not normally overridden elsewhere in the project file. This group is not configuration dependent and so only one Globals group generally exists in the project file. -->
<PropertyGroup Label="Globals" />
<!-- This property sheet contains the default settings for a VC++ project. It contains definitions of all the project settings such as Platform, PlatformToolset, OutputPath, TargetName, UseOfAtl, etc. and also all the item definition group defaults for each known item group. In general, properties in this file are not tool-specific. --> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<!-- This property group has an attached configuration condition (such as Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'") and comes in multiple copies, one per configuration. This property group hosts configuration-wide properties. These properties control the inclusion of system property sheets in Microsoft.Cpp.props. E.g. if we define the property <CharacterSet>Unicode</CharacterSet>, then the system property sheet microsoft.Cpp.unicodesupport.props will be included (as can be seen in the Property Manager). Indeed, in one of the imports of Microsoft.Cpp.props, we can see the line: <Import Condition="'$(CharacterSet)' == 'Unicode'" Project="$(VCTargetsPath)\microsoft.Cpp.unicodesupport.props"/> -->
<PropertyGroup Label="Configuration" />
<!-- This property sheet (directly or via imports) defines the default values for many tool-specific properties such as the compiler’s Optimization, WarningLevel properties, Midl tool’s TypeLibraryName property, etc. In addition, it imports various system property sheets based on configuration properties defined in the property group immediately above. -->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<!-- This group contains imports for the property sheets that are part of Build Customizations (or Custom Build Rules as this feature was called in earlier editions). A Build Customization is defined by up to three files – a .targets file, a .props file and .xml file. This import group contains the imports for the .props file. --> <ImportGroup Label="ExtensionSettings" />
<!-- This group contains the imports for user property sheets. These are the property sheets you add through the Property Manager view in VS. The order in which these imports are listed is relevant and is reflected in the Property Manager. The project file normally contains multiple instances of this kind of import group, one for each project configuration. -->
<ImportGroup Label="PropertySheets" />
<!-- UserMacros are as variables used to customize your build process. E.g. you can define a user macro to define your custom output path as $(CustomOutpuPath) and use it to define other variables. This property group houses such properties. Note that in VS2010, this group is not populated by the IDE since we do not support user macros for configurations (we do for property sheets though). -->
<PropertyGroup Label="UserMacros" />
<!-- This property group normally comes with a configuration condition attached. You will also see multiple instances of the property group, one per configuration. It differs in its identity from the other property groups above by the fact that it does not have a label (to look at it in another way, it has a label that is equal to the empty string). This group contains project configuration level settings. These settings apply to all files that are part of the specified item group. Build Customization item definition metadata also gets initialized here. -->
<PropertyGroup />
<!-- Similar to the property group immediately above, but it contains item definitions and item definition metadata instead of properties. -->
<ItemDefinitionGroup />
<!-- Contains the items (source files, etc.) in the project. You will generally have multiple item groups – one per item type. --> <ItemGroup />
<!-- Defines (directly or via imports) VC++ targets such as build, clean, etc. --> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<!-- This group contains imports for the Build Customization target files. --> <ImportGroup Label="ExtensionTargets" />
</Project>