Visual Studio Code:如何配置“dotnet”在编译时不显示警告

Los*_*ost 5 c# visual-studio-code asp.net-core

好的。我使用 .NET Core 并在 Mac 计算机上使用 Visual Studio Code。现在,每当我运行 C# 项目时,Visual Studio Code 都会显示这条恼人的消息:

preLaunch 任务“build”以退出代码 1 终止

它向我显示了单击名为“显示问题”的按钮的选项。当我单击此按钮时,它只显示警告消息。

现在,如果出现错误,那么可以看到此消息。但事实是,每次出现警告时它都会显示此消息(对我来说这是可以的)。这很烦人。有没有办法可以将 Visual Studio Code 配置为不显示警告等消息?

ami*_*ali 5

为了禁用警告,您应该在文件中-nowarn添加:argstasks.json

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


Bar*_*r J 3

可能是你的文件有问题task.json。检查文件的参数并确保构建指向正确的位置:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/MyProject.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)