【问题标题】:MSBuild - The attribute "Text" in element <Message> is unrecognizedMSBuild - 元素 <Message> 中的属性“文本”无法识别
【发布时间】:2020-06-22 15:30:04
【问题描述】:

所以我有一个 .target 文件,它通过另一个 .target 文件解析以获取构建配置信息。它试图检索的标记示例是:

<bldConfiguration>Debug|x64; Release|x64</bldConfiguration>

执行检索的代码是:

<ItemGroup>
    <tempMap Include="$(bldConfiguration)"/>
        <Configs Include="@(tempMap)">
            <Configuration>$([System.String]::new('%(tempMap.Identity)').split("|")[0])</Configuration>
                <Platform>$([System.String]::new('%(tempMap.Identity)').split("|")[1])</Platform>
        </Configs>
    </tempMap>
</ItemGroup>

我在 Platform 属性上收到错误消息,指出索引超出范围。基于 ('%(tempMap.Identity)') 正在拆分的字符串是 Debug|x64 和 Release|x64 所以理论上它不应该超出范围。如果您看到我的错误,请随时纠正我。

当我尝试输出 Configuration 中包含的属性时,我可以看到值是什么:

<Message Text="$([System.String]::new('%(tempMap.Identity)').split("|")[0])">

我收到一条错误消息,提示“无法识别元素中的属性文本。”

如何将 or 属性“打印”到控制台或登录 MSBuild 以便查看结果?我很难调试这些标记 .target 文件。

谢谢!

【问题讨论】:

    标签: debugging split msbuild output target


    【解决方案1】:

    我引用https://github.com/MicrosoftDocs/visualstudio-docs/issues/5666#issuecomment-673773163

    尝试在目标以外的其他地方使用消息和文本时可能会出错。

    (同样适用于

    【讨论】:

      猜你喜欢
      • 2010-11-13
      • 2019-08-10
      • 1970-01-01
      • 2021-11-19
      • 2018-11-01
      • 2019-01-11
      • 2019-03-25
      • 2019-05-02
      • 2019-10-18
      相关资源
      最近更新 更多