How to change clcompile property for all projects... ask a question
- Thursday, January 12,201 pmChandrap
65 points
0We have a requirement I. e. we do not want to modify vcxproj files but have an import. prop file in. vcxproj. this prop file will be imported only if the file exists. the import will be at the bottom of. vcxproj so that it is the last file that is being imported. in the custom prop file we want to override clcompile \ link options I. e. override the values that exist in. vcxproj File
We tried the following but it does not work I. e. vcxproj file has debuginformationformat set to "editandcontinue" while custom. user. props file has "programdatabase" value for debuginformationformat. the debuginformationformat value does not get set to "programdatabase ". how do we achieve the above requirement.
Each and every. vcxproj file will have the following Import Statement
<Import project = "$ (dirname) \ custom. User. Props" condition = "exists ('$ (dirname) \ custom. User. Props')"/>
$ (Dirname) \ custom. User. Props will have the following:
<? XML version = "1.0" encoding = "UTF-8"?>
<Project defaulttargets = "build" toolsversion = "4.0" xmlns = "http://schemas.microsoft.com/developer/msbuild/2003">
<Itemdefinitiongroup>
<Clcompile>
<Debuginformationformat> programdatabase </debuginformationformat>
</Clcompile>
</Itemdefinitiongroup>
</Project>
- Edited by chandrapThursday, January 12,201 pm
-
- Friday, January 13,201 AMYi Feng liuis
9,705 pointsmoderator
0Hi chandrap,
I think your idea shold work, And I tested it on my side. The prop file is as following:
<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ImportGroup Label="PropertySheets" /> <PropertyGroup Label="UserMacros" /> <PropertyGroup /> <ItemDefinitionGroup> <ClCompile> <DebugInformationFormat>OldStyle</DebugInformationFormat> </ClCompile> </ItemDefinitionGroup> <ItemGroup /></Project>
And the last few lines of vcxproj is as following:
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup> <Import Project ="test1.props" Condition= "exists('test1.prop')"/> </ImportGroup> <Target Name="msg"> <Message Text=" %(ClCompile.DebugInformationFormat)" /> </Target></Project>I defined a target called MSG to show the value of debuginformationformat, as the result, if the prop file exists, it is oldstyle, otherwise it is editandcontinue.
If I misunderstand you, please let me know.
Yi
Yi Feng Li [MSFT]
Msdn community support | feedback to us
- Marked as answer by Yi Feng limoderatorWednesday, February 01,201 2 AM
-
- Saturday, January 14,201 AMChandrap
65 points
0Hi Yi,
I used your files and still does not work. My environment is W7 64bit, vs2010 SP1. I do not even see the message (assuming the message will come in the output window ).
Thanks
Chandra
My vcxproj:
<?xml version="1.0" encoding="utf-8"?><Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{2A75CB1A-378C-4806-B088-09EFFBA2F499}</ProjectGuid> <Keyword>Win32Proj</Keyword> <RootNamespace>TestProps</RootNamespace> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <LinkIncremental>true</LinkIncremental> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <LinkIncremental>false</LinkIncremental> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <PrecompiledHeader>Use</PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTPROPS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader>Use</PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TESTPROPS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> </ItemDefinitionGroup> <ItemGroup> <None Include="ReadMe.txt" /> </ItemGroup> <ItemGroup> <ClInclude Include="stdafx.h" /> <ClInclude Include="targetver.h" /> <ClInclude Include="TestProps.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </PrecompiledHeader> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </PrecompiledHeader> </ClCompile> <ClCompile Include="stdafx.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> </ClCompile> <ClCompile Include="TestProps.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup> <Import Project ="test1.props" /> </ImportGroup> <Target Name="msg"> <Message Text=" %(ClCompile.DebugInformationFormat)" /> </Target> <ImportGroup Label="ExtensionTargets"> </ImportGroup></Project>
Test1.props:
<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ImportGroup Label="PropertySheets" /> <PropertyGroup Label="UserMacros" /> <PropertyGroup /> <ItemDefinitionGroup> <ClCompile> <DebugInformationFormat>OldStyle</DebugInformationFormat> </ClCompile> </ItemDefinitionGroup> <ItemGroup /></Project>
- Edited by chandrapSaturday, January 14,201 2 AM
-
- Monday, January 16,201 AMYi Feng liuis
9,705 pointsmoderator
0Hi chandrap,
The "MSG" is used to test whether the props changes the compile option.
You can call msbuild yourproj. vcxproj/T: MSG to execute the MSG target only under vs2010 command line prompt. The current value of debug information will be printout.
Cheers,
Yi
Yi Feng Li [MSFT]
Msdn community support | feedback to us
- Tuesday, January 17,201 2: 29 AMJerryxia
0 Points
0Hi Yi,
I have the same requirement. I tried your way. The value will be printed out as expected. But there is only one thing I am confused with. Let's takeLinkincrementalAs reference. I changed 'test1. prop' to update the valueLinkincrementalInto true for both Debug and release configuration. And the value will be printed out as expected. But when I checked out the property page dialog, the value is stillFalseWith release configuration. Is this by design? Which value the compiler will take when I build the project with IDE?
Thanks,
Jerry
- Tuesday, January 17,201 2 AMYi Feng, liunisys
155 points
0IDE just use vcproj file to display the properties, it doesn' t phrase it in deep.
When building, IDE callmsbuild, therefore it will be "true" as same as you saw from msbuild command line
- Marked as answer by Yi Feng limoderatorWednesday, February 01,201 2 AM
-
- Monday, January 23,201 2: 59 AMYi Feng liuis
9,705 pointsmoderator
0Hello,
I am writing to check the status of the issue on your side. wocould you mind letting us know the result of the suggestions?
Yi
Yi Feng Li [MSFT]
Msdn community support | feedback to us
- Monday, January 23,201 pmChandrap
65 points
0Yes it works. But it is confusing that we cannot see the changed property values from IDE.
Thanks
Chandra
- Tuesday, January 24,201 2: 15 amYi Feng liuis
9,705 pointsmoderator
0Hi Chandra,
As cherubim said, IDE use the information in vcproj file only to show the property page. Any indirect property from "import" will not be converted Ted on the IDE.
Regards,
Yi
Yi Feng Li [MSFT]
Msdn community support | feedback to us
- Friday, January 27,201 2 AMYi Feng liuis
9,705 pointsmoderator
0Hello,
I am writing to check the status of the issue on your side. wocould you mind letting us know the result of the suggestions?
Yi