簡體   English   中英

在 Visual Studio Code 中發布版本

[英]Release build in Visual Studio Code

在構建我的 C# 項目時,如何在 VS Code 中切換到發布配置?

現在我使用Ctrl+F5Debug -> 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+BCommand Palette將讓您在Build ReleaseBuild 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM