如何让 <Message> 出现在 Visual Studio 的错误列表中?

问题描述 投票:0回答:1

我已将以下任务添加到我的项目中:

<Target Name="Foo" AfterTargets="Build">
    <Message Importance="high" Text="Some text." />
</Target>

消息出现在 Output 窗口中,但不在 Error List 窗口中。

有办法做到吗?

我检查了其他涉及错误列表的问题,我不太乐观。

visual-studio visual-studio-2022 error-list
1个回答
0
投票

您可以将 警告任务 添加到您的项目中。

这是一个例子:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ValidateCommandLine">
    <Warning
        Text=" The 0 property was not set on the command line."
        Condition="'$(0)' == ''" />
    <Warning
        Text=" The FREEBUILD property was not set on the command line."
        Condition="'$(FREEBUILD)' == ''" />
</Target>
...

请注意,警告任务只能在构建过程之前执行。

© www.soinside.com 2019 - 2024. All rights reserved.