在Visual Studio代码中发布版本

sas*_*alm 8 c# visual-studio-code

在构建我的C#项目时,如何在VS Code中切换到Release配置?

现在我启动我的应用程序Ctrl+F5或者Debug -> Start Without Debugging也可以构建它,但这只会创建一个调试版本bin/Debug.BuildVS Code中没有菜单.

这是我的tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/dotnetcore-test.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

V B*_*ota 10

像这样编辑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"
        }        
    ]
}
Run Code Online (Sandbox Code Playgroud)

那么当你按下Ctrl+Shift+BCommand Palette会让你选择Build ReleaseBuild Debug

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


use*_*944 5

您可以通过终端执行发布构建:

dotnet build -c release
Run Code Online (Sandbox Code Playgroud)

如果要在发布中运行,请使用:

dotnet run -c release
Run Code Online (Sandbox Code Playgroud)

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