C# Preprocessor

·

1 min read

Table of contents

Error and Warning

  • #error: Invoke compiler error with message

  • #warning: Invoke compiler warning with message

#warning This is warning
#error This is error

Output

Because of error directive, dotnet build Program.cs will print below output.

$ dotnet build .\Program.cs
MSBuild version 17.6.0-preview-23122-01+4b5e303b3 for .NET
C:\Users\archdsp\Projects\HelloWorld\Program.cs(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 
1, position 1.

Build FAILED.

C:\Users\archdsp\Projects\HelloWorld\Program.cs(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 
1, position 1.
    0 Warning(s)
    1 Error(s)