Visual studio code VS代码工作区启动配置部分不工作
我的VS代码工作区文件包括启动配置和任务部分,因此开发人员可以在本地运行Azure功能 但是,工作区文件中的启动配置将被忽略 如果我使用相同的内容添加Visual studio code VS代码工作区启动配置部分不工作,visual-studio-code,azure-functions,vscode-settings,vscode-tasks,Visual Studio Code,Azure Functions,Vscode Settings,Vscode Tasks,我的VS代码工作区文件包括启动配置和任务部分,因此开发人员可以在本地运行Azure功能 但是,工作区文件中的启动配置将被忽略 如果我使用相同的内容添加launch.json和tasks.json,它就可以正常工作 .code工作区: { "folders": [ { "path": "." } ], "launch": { "configurations": [ {
launch.json
和tasks.json
,它就可以正常工作
.code工作区
:
{
"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",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "clean release",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release",
"problemMatcher": "$msCompile"
},
{
"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
文件
我重现了你的错误 这就是解决方案: 请注意,全局启动配置需要您在用户设置中添加
launch
您的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",
"request": "launch",
"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",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "clean release",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release",
"problemMatcher": "$msCompile"
},
{
"type": "func",
"dependsOn": "build",
"options": {
"cwd": "${workspaceFolder}/src/ProjectAbc/bin/Debug/netcoreapp2.2"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-watch"
}
]
}
}
}
那你就永远不会面对这个错误。VS代码将不再尝试创建launch.json文件
然后它应该工作,请注意,您的任务配置是不正确的!您当前的问题来自VSCode未读取的任务配置。修改它,它应该可以正常工作
这对我不起作用。我收到一个错误:“找不到func主机启动”@DerDani81找不到func主机启动?您是否安装了函数核心工具,以及在本地或全局上的安装位置?是的,安装了globalOutput:“错误:func任务检测没有为以下配置贡献任务:{”type:“func”,“dependsOn:“build”,“command:“host start”,“isBackground:”true,“problemMatcher:“$func watch”“}将忽略该任务。”该任务在.code工作区中配置file@DerDani81奇怪…这对我来说很好。好的。我会研究,如果解决了,我会更新答案。你解决了吗?