Visual Studio 2022 Error List does not display custom MSBuild warning codes (INC1001, MSB1001) in legacy .NET Framework C# projects

Андрей Колесов 0 Reputation points
2026-11-16T11:51:19.26+00:00

Hello,

I'm experiencing an issue with Visual Studio 2022 (17.14.45) where custom MSBuild warning codes are not displayed in the Code column of the Error List for a legacy C# project targeting .NET Framework 4.8.

The same warning codes are displayed correctly in a modern SDK-style project targeting .NET 10.

1. Initial problem

I have a custom console application (Incrementor.exe) that runs during the build process using PreBuildEvent and PostBuildEvent.

It produces warnings using Console.WriteLine() in the standard MSBuild diagnostic format:

Console.WriteLine($"Incrementor : warning INC1001: {message}");

Visual Studio correctly recognizes the message as a warning, but the Code column remains empty.

2. Reproduction without the external application

To exclude any issues with my console application, I added the following target directly to the legacy .csproj:

<Target Name="TestWarningCodes" AfterTargets="Build">
    <Exec Command="echo Incrementor.exe(1,1): warning INC1001: TEST INC" />
    <Exec Command="echo Incrementor.exe(1,1): warning CS1001: TEST CS" />
    <Exec Command="echo Incrementor.exe(1,1): warning MSB1001: TEST MSB" />
</Target>

The results in Visual Studio's Error List were:

Warning Code column Description
INC1001 Empty TEST INC
CS1001 CS1001 TEST CS
MSB1001 Empty TEST MSB

Only the warning with the CS prefix has its code displayed.

3. Testing the native MSBuild Warning task

I also tested the built-in MSBuild Warning task:

<Target Name="TestWarning" AfterTargets="Build">
    <Warning Code="INC1001" Text="Test warning from MSBuild Warning task" />
</Target>

The warning appears in the Error List, but its Code column is still empty.

This indicates that the problem is not specific to parsing the output of Exec or Console.WriteLine().

4. Comparison with SDK-style projects

I performed the same Exec test in an SDK-style C# project targeting net10.0-windows.

In that project, Visual Studio correctly displays the custom warning code INC1001.

The issue appears to affect legacy, non-SDK-style C# projects.

5. MSBuild command-line verification

I ran the following command using Visual Studio Developer PowerShell:

msbuild LibDbUtils.csproj /t:Rebuild /bl:build.binlog

Environment:

  • Visual Studio 2022 Community, version 17.14.45

MSBuild 17.14.60

.NET Framework 4.8

Legacy, non-SDK-style C# project

The command-line output correctly displays all three warnings:

Incrementor.exe(1,1): warning INC1001: TEST INC
Incrementor.exe(1,1): warning CS1001: TEST CS
Incrementor.exe(1,1): warning MSB1001: TEST MSB

The binary MSBuild log also contains warning events with their corresponding codes.

Therefore, the warning codes appear to be preserved by MSBuild but are not consistently displayed in Visual Studio's Error List.

6. Questions

Why does the Visual Studio Error List display CS1001 but omit INC1001 and MSB1001 for the same legacy C# project?

Is this a known limitation or bug in the legacy C# project system in Visual Studio 2022?

Is there a supported way to display custom MSBuild warning codes in the Error List for non-SDK-style .NET Framework projects?

Can this behavior be configured without converting the project to SDK-style format?

I would like to keep my custom INC#### diagnostic codes rather than using the CS#### prefix reserved for C# compiler diagnostics.

Thank you for your assistance.Hello,

I'm experiencing an issue with Visual Studio 2022 (17.14.45) where custom MSBuild warning codes are not displayed in the Code column of the Error List for a legacy C# project targeting .NET Framework 4.8.

The same warning codes are displayed correctly in a modern SDK-style project targeting .NET 10.

1. Initial problem

I have a custom console application (Incrementor.exe) that runs during the build process using PreBuildEvent and PostBuildEvent.

It produces warnings using Console.WriteLine() in the standard MSBuild diagnostic format:

Console.WriteLine($"Incrementor : warning INC1001: {message}");

Visual Studio correctly recognizes the message as a warning, but the Code column remains empty.

2. Reproduction without the external application

To exclude any issues with my console application, I added the following target directly to the legacy .csproj:

<Target Name="TestWarningCodes" AfterTargets="Build">
    <Exec Command="echo Incrementor.exe(1,1): warning INC1001: TEST INC" />
    <Exec Command="echo Incrementor.exe(1,1): warning CS1001: TEST CS" />
    <Exec Command="echo Incrementor.exe(1,1): warning MSB1001: TEST MSB" />
</Target>

The results in Visual Studio's Error List were:

Warning Code column Description
INC1001 Empty TEST INC
CS1001 CS1001 TEST CS
MSB1001 Empty TEST MSB

Only the warning with the CS prefix has its code displayed.

3. Testing the native MSBuild Warning task

I also tested the built-in MSBuild Warning task:

<Target Name="TestWarning" AfterTargets="Build">
    <Warning Code="INC1001" Text="Test warning from MSBuild Warning task" />
</Target>

The warning appears in the Error List, but its Code column is still empty.

This indicates that the problem is not specific to parsing the output of Exec or Console.WriteLine().

4. Comparison with SDK-style projects

I performed the same Exec test in an SDK-style C# project targeting net10.0-windows.

In that project, Visual Studio correctly displays the custom warning code INC1001.

The issue appears to affect legacy, non-SDK-style C# projects.

5. MSBuild command-line verification

I ran the following command using Visual Studio Developer PowerShell:

msbuild LibDbUtils.csproj /t:Rebuild /bl:build.binlog

Environment:

Visual Studio 2022 Community, version 17.14.45

MSBuild 17.14.60

.NET Framework 4.8

Legacy, non-SDK-style C# project

The command-line output correctly displays all three warnings:

Incrementor.exe(1,1): warning INC1001: TEST INC
Incrementor.exe(1,1): warning CS1001: TEST CS
Incrementor.exe(1,1): warning MSB1001: TEST MSB

The binary MSBuild log also contains warning events with their corresponding codes.

Therefore, the warning codes appear to be preserved by MSBuild but are not consistently displayed in Visual Studio's Error List.

6. Questions

Why does the Visual Studio Error List display CS1001 but omit INC1001 and MSB1001 for the same legacy C# project?

Is this a known limitation or bug in the legacy C# project system in Visual Studio 2022?

Is there a supported way to display custom MSBuild warning codes in the Error List for non-SDK-style .NET Framework projects?

Can this behavior be configured without converting the project to SDK-style format?

I would like to keep my custom INC#### diagnostic codes rather than using the CS#### prefix reserved for C# compiler diagnostics.

Thank you for your assistance.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 85,421 Reputation points
    2026-11-16T16:38:05.4466667+00:00

    the issue is that the sdk style projects use different build tools (dotnet cli or new msbuild). these tools are command line and error processing has been changed. as .net48 projects are legacy, they are not likely to be updated (they work the way they work).

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.