[英]Release build in Visual Studio Code
在構建我的 C# 項目時,如何在 VS Code 中切換到發布配置?
現在我使用Ctrl+F5
或Debug -> Start Without Debugging
啟動我的應用程序,它也構建它,但這只會在bin/Debug
處創建一個調試構建。 VS Code 中沒有Build
菜單。
這是我的tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/dotnetcore-test.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
像這樣編輯 task.json:
{
"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"
}
]
}
然后當您按Ctrl+Shift+B
, Command Palette
將讓您在Build Release
和Build Debug
之間進行選擇
來源: https : //docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x
您可以通過終端執行發布構建:
dotnet build -c release
如果要在發布中運行,請使用:
dotnet run -c release
來源:https ://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build
你可以在沒有 tasks.json 的情況下做到這一點,但使用 Launch.json
這是我一直用來通過 F5 構建我的 C# 項目的配置: Gist
終端->運行任務... -> 選擇要運行的任務名稱
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.