dotnet核心中的重复错误消息

Jai*_*ime 0 msbuild .net-core visual-studio-code dotnet-cli

重现步骤

dotnet new console
(introduce a bug in Program.cs)
dotnet restore
dotnet build
Run Code Online (Sandbox Code Playgroud)

典型的输出为:

Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(5,5): error CS0116: A namespace cannot directly contain members such as fields or methods [/Users/xxx/Documents/myproj/myproj.csproj]

Build FAILED.

Program.cs(5,5): error CS0116: A namespace cannot directly contain members such as fields or methods [/Users/xxx/Documents/myproj/myproj.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.77
Run Code Online (Sandbox Code Playgroud)

您可以看到错误CS0116被报告两次。

我的问题是:有没有办法避免重复报告错误?

Mar*_*ich 5

第二个错误是控制台记录器摘要的一部分。可以通过传入/clp:NoSummarymsbuild 来禁用它。但是,当它是的第一个msbuild参数时,CLI中当前存在一个错误dotnet build。在使其生效之前,添加任何其他msbuild命令。由于您要减少冗长,因此我们仅使用/nologo变通方法:

dotnet build -c Release /nologo /clp:NoSummary
Run Code Online (Sandbox Code Playgroud)

但是,如果直接使用msbuild,它会很好用:

dotnet msbuild /clp:NoSummary /p:Configuration=Release
Run Code Online (Sandbox Code Playgroud)

在即将发布的2.0.0版本中,CLI始终会覆盖它的summary参数,dotnet build因此您必须改为使用它dotnet msbuild在GitHub上打开了一个问题