【发布时间】:2021-05-29 22:46:42
【问题描述】:
如果您像这样在自定义构建工具中设置“将输出添加到项目类型”属性,
它将在.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文件中设置的相同时它不起作用?
【问题讨论】:
-
或许您可以尝试将其添加到ItemMetadata group。
-
@DylanZhu-MSFT 是的,我忘记更新了,我在发布这个问题后已经尝试过了。也不行。
-
您可以尝试将ItemGroup移出Target
-
@DylanZhu-MSFT 感谢您的建议。但是,这也不起作用......
标签: visual-studio msbuild msbuild-target