VS Code Workspace启动配置部分不起作用

我的VS Code工作区文件包含启动配置和任务部分,因此开发人员可以在本地运行Azure Functions。

但是,它暗示了将忽略工作空间文件中的启动配置。

如果我将launch.jsontasks.json添加到相同的内容,它将正常工作。

.code-workspace

{
    "folders": [
        {
            "path": "."
        }
    ],"launch": {
        "configurations": [
            {
                "name": "Attach to .NET Functions","type": "coreclr","request": "attach","processId": "${command:azureFunctions.pickProcess}"
            }
        ]
    },"tasks": {
        "version": "2.0.0","tasks": [
            {
                "label": "clean","command": "dotnet","args": [
                    "clean","/property:GenerateFullPaths=true","/consoleloggerparameters:NoSummary"
                ],"type": "process","problemMatcher": "$msCompile"
            },{
                "label": "build","args": [
                    "build","dependsOn": "clean","group": {
                    "kind": "build","isDefault": true
                },{
                "label": "clean release","--configuration","Release",{
                "label": "publish","args": [
                    "publish","dependsOn": "clean release",{
                "type": "func","dependsOn": "build","options": {
                    "cwd": "${workspaceFolder}/src/ProjectAbc/bin/Debug/netcoreapp2.2"
                },"command": "host start","isBackground": true,"problemMatcher": "$func-watch"
            }
        ]
    }
}

预期行为: 如果我按F5,则应使用工作区设置中的lauch配置来构建和运行Azure函数。

实际行为: 如果我按F5,VS Code会根据环境创建一个launch.json文件。

VS Code Workspace启动配置部分不起作用

zhuhao568 回答:VS Code Workspace启动配置部分不起作用

我已重现您的错误,

这是解决方案:

请注意,全局启动配置需要您在用户设置中添加launch

Have a look of this

您的settings.json文件应如下所示:

{
    "azureFunctions.deploySubpath": ".","azureFunctions.projectLanguage": "JavaScript","azureFunctions.projectRuntime": "~2","debug.internalConsoleOptions": "neverOpen","azureFunctions.preDeployTask": "npm prune","launch": {
        "version": "0.2.0","configurations": [
        {
            "name": "Attach to Node Functions","type": "node","request": "launch","port": 9229,"preLaunchTask": "func: host start","outFiles": [
                "${workspaceRoot}/TimerTrigger/index.js"
            ]
        },{
            "type": "node","name": "Launch Program","program": "${workspaceFolder}\\index.js"
        }
    ]
    }
        //---------------------------
"tasks":{
    "version": "2.0.0","tasks": {
    "version": "2.0.0","tasks": [
        {
            "label": "clean","command": "dotnet","args": [
                "clean","/property:GenerateFullPaths=true","/consoleloggerparameters:NoSummary"
            ],"type": "process","problemMatcher": "$msCompile"
        },{
            "label": "build","args": [
                "build","dependsOn": "clean","group": {
                "kind": "build","isDefault": true
            },{
            "label": "clean release","--configuration","Release",{
            "label": "publish","args": [
                "publish","dependsOn": "clean release",{
            "type": "func","dependsOn": "build","options": {
                "cwd": "${workspaceFolder}/src/ProjectAbc/bin/Debug/netcoreapp2.2"
            },"command": "host start","isBackground": true,"problemMatcher": "$func-watch"
        }
    ]
    }
}
    }

那么您将永远不会遇到该错误。 VS Code将永远不会尝试再次创建launch.json文件。

然后它应该可以工作,请注意您的任务配置不正确!您当前的问题来自于VSCode无法读取的任务配置。修改它,它应该可以正常工作。

enter image description here

本文链接:https://www.f2er.com/2796981.html

大家都在问