0

如果您像这样在自定义构建工具中设置“将输出添加到项目类型”属性,

将输出添加到项目类型

它将在.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文件中设置的相同?

4

1 回答 1

0

通过 Visual Studio 反馈得到答案。推杆

<ItemGroup Condition="'@(_SECompile)' != ''"> <ClCompile Include="%(_SECompile.Outputs)" Condition="'%(_SECompile.ExcludedFromBuild)' != 'true'" /> </ItemGroup>

在目标中会起作用。

原文链接:https ://developercommunity.visualstudio.com/t/Setting-CustomBuilds-OutputItemType-in​​/1452940?entry=myfeedback&ref=native&refTime=1624191549072&refUserId=95d48ba8-b75f-4896-8bf5-5745bf012b77

于 2021-06-21T00:19:47.477 回答