问题
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