如果您像这样在自定义构建工具中设置“将输出添加到项目类型”属性,
它将在.vcxproj
文件中添加以下行:
<OutputItemType>ClCompile</OutputItemType>
但是,当我定义自己的目标并尝试使用它时,它不起作用。
(...)
<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 =""
/>
(...)
python 脚本正在运行并且正在输出消息,因此其他属性正在运行。但OutputItemType
不起作用。
我想要做的基本上是做同样的事情CustomBuild
,它的参数用特定的值预定义。
所以问题是:为什么当您在目标中手动设置它时它不起作用,而它应该与在vcxproj
文件中设置的相同?