gpt4 book ai didi

msbuild - 如何将 ItemList 添加到 MSBuild 中的默认 ItemDefinitionGroup 元数据?

转载 作者:行者123 更新时间:2023-12-02 08:53:28 24 4
gpt4 key购买 nike

我正在尝试将给定目录中的所有文件添加到 ClCompile 元数据的 ForcedUsingFiles 参数中。

我使用以下代码:

<ItemGroup>
<ForcedUsingFilesList Include="c:\path\to\files\*" />
</ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
<ForcedUsingFiles>@(ForcedUsingFilesList)</ForcedUsingFiles>
</ClCompile>
</ItemDefinitionGroup>

但我收到错误

The value "@(ForcedUsingFilesList)" of metadata "ForcedUsingFiles" contains an item list expression. Item list expressions are not allowed on default metadata values.

知道如何解决此错误吗?

谢谢

最佳答案

啊,看起来我需要添加一个额外的间接层来将 ItemList 转换为 Property。然后我可以将该属性粘贴到 ItemDefinitionGroup 中。

下面的代码可以解决这个问题,但希望有一种更直接的方法来做到这一点:

  <ItemGroup>
<ForcedUsingFilesList Include="c:\path\to\files\*" />
</ItemGroup>
<PropertyGroup>
<ForcedUsingFilesList2>
@(ForcedUsingFilesList->'%(FullPath)')
</ForcedUsingFilesList2>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<ForcedUsingFiles>$(ForcedUsingFilesList2)</ForcedUsingFiles>
</ClCompile>
</ItemDefinitionGroup>

关于msbuild - 如何将 ItemList 添加到 MSBuild 中的默认 ItemDefinitionGroup 元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6780985/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com