Skip to content

Commas vs semicolons in WarningsAsErrors tag #45590

Closed
@dimodi

Description

@dimodi

Type of issue

Code doesn't work

Description

Semicolons vs Commas in WarningsAsErrors

Hello,

Please consider using semicolons ; instead of commas , in the example for <WarningsAsErrors>...</WarningsAsErrors>. My tests show that only semicolons work when you have custom error codes that come from custom MSBuild tasks. See the screenshots at the bottom of this message.

-warnaserror Switch

In addition, please link the MSBuild Switches CLI reference from the table at the top of the discussed article or from the WarningsAsErrors section. It took me several attempts and dedication to find how to use -warnaserror with multiple error codes. There are several working syntax options with one code, which are easily found when searching in Google and StackOverflow. However, there seems to be just one reliable approach with multiple error codes, which is documented only on this page, namely, semicolons plus quotation marks:

dotnet build -warnaserror:"TKL002;TKL101;TKL004"

Screenshots

Commas

Image

Semicolons

Image

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#warningsaserrors-and-warningsnotaserrors

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/compiler-options/errors-warnings.md

Document Version Independent Id

e57ac82b-307e-163b-8172-52644b3a6baa

Platform Id

c779c5b8-68cc-a425-165e-cd701a8e8824

Article author

@BillWagner

Metadata

  • ID: 26ef35c2-6df4-26f8-32b2-9b50eb76c037
  • PlatformId: c779c5b8-68cc-a425-165e-cd701a8e8824
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues


Associated WorkItem - 416795

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions