Release build in Visual Studio Code

You can perform a release build via the terminal with:

dotnet build -c release

If you want to run in release, use:

dotnet run -c release

Source: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build


you can just do that without tasks.json , but with Launch.json

Here is a configuration I always use to build my C# projects by F5 : Gist


edit the task.json like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "build Debug",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/dotnetcore-test.csproj"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "taskName": "build Release",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/dotnetcore-test.csproj",
                "-c",
                "Release"
            ],
            "problemMatcher": "$msCompile"
        }        
    ]
}

then when you press Ctrl+Shift+B the Command Palette will let you choose between Build Release and Build Debug

source: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x