How to set compiler options in VS Code and/or .NET Core?

你。 提交于 2020-01-30 03:32:30

问题


I'm trying to set the -checked compiler option for a C# library project written over .NET Core, using VS Code as the IDE. How can I do this?


回答1:


When you open your project/solution with VS Code, it will create a directory called .vscode, within it there will be a tasks.json file

(this directory and file are created the first time that you hit F5 within VS Code)

Taking a look at this file, you'll that it takes a format similar to the following:

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

(you may have more task entries)

You can add individual arguments to each task by adding a string to its args array. In the above example I am calling the CLI command dotnet and passing it the arguments build and ${workspaceFolder}/project.csproj



来源:https://stackoverflow.com/questions/56676976/how-to-set-compiler-options-in-vs-code-and-or-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!