MSBuild Managed vs Unmanaged property
Usually in the vcxproj file for managed compilation (afaik), there are at least two things that change in our C ++ / cli property master table used for all cli projects: the property is CLRSupport
set to true and the ClCompile
ItemGroup has metadata CompileAsManaged
set as true. You can check either of these or both. This sets the one that prints the values:
<Target Name="CheckManaged">
<ItemGroup>
<ClCompile Include="dummy.cpp" />
</ItemGroup>
<PropertyGroup>
<CompileAsManaged>@(ClCompile->AnyHaveMetadataValue('CompileAsManaged','true'))</CompileAsManaged>
</PropertyGroup>
<Message Text="CompileAsManaged is $(CompileAsManaged) and CLRSupport is $(CLRSupport)" />
<ItemGroup>
<ClCompile Remove="dummy.cpp" />
</ItemGroup>
</Target>
As you can see, getting the metadata value CompileAsManaged
requires some processing: I add the item to the ClCompile group, because if the group is empty, you cannot use CompileAsManaged; usually you can just omit it.
source to share
In C ++, every item in ClCompile (list of source files) has a CompileAsManaged
metadata value . Setting properties is tricky as it can vary for each source file, but simpler if you only expect (and support) disabling the project-wide setting. Switch this to the IDE and see what changes in vcxproj. It has several different meanings.
source to share