Lost
Lost

Reputation: 13565

Visual Studio Code: How to configure 'dotnet' not to show warnings when compiling

OK. I am in .NET Core and using Visual Studio Code on a Mac machine. Now, whenever I run my C# project then Visual Studio Code shows this annoying message:

The preLaunch task 'build' terminated with exit code 1

It shows me the option to click on a button called "Show problems". When I click on this button, it only shows the warning messages.

Now, if it was errors then it's OK to see this message. But the fact that it shows this message every time there are warnings (which to me is OK). That is very annoying. Is there a way I can configure Visual Studio Code to not show these messages on things like warnings?

Upvotes: 5

Views: 5192

Answers (2)

amirali
amirali

Reputation: 1964

In order to disable warnings, you should add -nowarn to args in the tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/MyProject.csproj",
                "-nowarn" // here
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

Upvotes: 5

Barr J
Barr J

Reputation: 10919

It might be a problem with your task.json file. Check the arguments of the file and make sure the build is pointing at the right location:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/MyProject.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

Upvotes: 3

Related Questions