Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release build in Visual Studio Code

Tags:

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"         }     ] } 
like image 634
sashoalm Avatar asked Dec 17 '17 12:12

sashoalm


People also ask

What is release build?

A release build uses optimizations. When you use optimizations to create a release build, the compiler will not produce symbolic debugging information.

What is difference between debug and release build?

Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.

How do I make a release build?

To generate a release build of your programSelect Release from the Solution Configuration drop-down list, which is on the Standard toolbar. On the Build menu, click Build.


2 Answers

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

like image 111
V Bota Avatar answered Oct 02 '22 13:10

V Bota


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

like image 33
user3256944 salutes Monica Avatar answered Oct 02 '22 11:10

user3256944 salutes Monica