If you set "Add Outputs to Item Type" property in Custom Build Tool like this,
It will add the following line in .vcxproj
file:
<OutputItemType>ClCompile</OutputItemType>
However, when I define my own target and try to use it, it doesn't work.
(...)
<Target Name="__SECompile" BeforeTargets="PreBuildEvent">
<ItemGroup>
<_SECompileMetadataSet Include="@(SECompile)">
<Message>Processing %(Identity)</Message>
<Outputs>$(ProjectDir)intermediate\%(Identity)</Outputs>
<Command>python (path to a python script) "%(FullPath)" "$(ProjectDir)intermediate\%(Identity)"</Command>
<OutputItemType>ClCompile</OutputItemType>
<LinkObjects>false</LinkObjects>
</_SECompileMetadataSet>
</ItemGroup>
(...)
(Below is just a copy-paste from Microsoft.CppCommon.targets)
<!-- Get out of date items (will create tlogs for all SECompile items) -->
<GetOutOfDateItems
Condition ="'$(SelectedFiles)' == ''"
Sources ="@(_SECompileMetadataSet)"
OutputsMetadataName ="Outputs"
DependenciesMetadataName ="AdditionalInputs"
CommandMetadataName ="Command"
TLogDirectory ="$(TLogLocation)"
TLogNamePrefix ="SECompile"
CheckForInterdependencies ="true"
>
<Output TaskParameter="OutOfDateSources" ItemName="_SECompile"/>
</GetOutOfDateItems>
<!-- Buidl items which can be built in parallel (ignored for selected files build)-->
<ItemGroup Condition="'$(SelectedFiles)' == ''">
<_ParallelSECompile Include="@(_SECompile)" />
</ItemGroup>
<ParallelCustomBuild
Condition ="'@(_ParallelSECompile)' != ''"
Sources ="@(_ParallelSECompile)"
MaxProcesses ="0"
MaxItemsInBatch ="0"
AcceptableNonZeroExitCodes =""
/>
(...)
The python script is running and the message is being output, so the other properties are functioning. But OutputItemType
doesn't work.
What I'm trying to do is basically do the exact same thing CustomBuild
does, with its arguments predefined with specific values.
So the question is:
Why doesn't it work when you set it manually in a target while it should be the same as it was set in the vcxproj
file?
Got an answer through Visual Studio Feedback. Putting
<ItemGroup Condition="'@(_SECompile)' != ''"> <ClCompile Include="%(_SECompile.Outputs)" Condition="'%(_SECompile.ExcludedFromBuild)' != 'true'" /> </ItemGroup>
in the target would work.