Reputation: 79685
When building my C# project, how can I switch to Release configuration in VS Code?
Right now I launch my application with Ctrl+F5
or Debug -> Start Without Debugging
which also builds it, but this creates only a debug build at bin/Debug
. There is no Build
menu in VS Code.
Here's my tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/dotnetcore-test.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
Upvotes: 35
Views: 45338
Reputation: 31
If you are using C#DevKit extension for .NET than:
Ctrl+Shift+P
or View -> Command Palette...
opens "Command Palette"Release
.Build with Ctrl+Shift+B
. If there's no bulid task, you will be prompted to choose one.
Run in "Terminal" window with dotnet run -c Release
.
Upvotes: 2
Reputation: 617
Edit the tasks.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://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x
Upvotes: 42
Reputation: 864
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://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build
Upvotes: 18