visual-studio-code - VS Code Workspace 启动配置部分不起作用
问题描述
我的 VS Code 工作区文件包含启动配置和任务部分,因此开发人员可以在本地运行 Azure Functions。
但似乎工作区文件中的启动配置将被忽略。
如果我添加launch.json
并tasks.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",
"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
基于环境创建文件。
解决方案
I have reproduce your error,
This is the solution:
Please notice that Global launch configuration need you to add launch
in user settings.
Your settings.json file should be like this:
{
"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"
}
]
}
}
}
Then you will never face that error. The VS Code will never try to create the launch.json file again.
Then It should work, please notice that your tasks configure is not correct! Your current problem comes from the tasks config not read by VSCode. Modify it and it should work fine.
推荐阅读
- javascript - jquery会自动将rgba转换为rgb吗?
- android - 停止服务如何影响服务中创建的线程?
- php - 计算shopify购物车页面中比较价格和小计之间的差异
- kubernetes - 在 kubernetes yaml 文件中为 OrientDb 指定 java 堆选项
- python - 使用 scrapy 抓取 Walmart.com 并获取“错误页面无法连接到服务器”
- sql - 为用户选择下次登录时间
- perl - Tesseract 无法识别 png 文件中的验证码,该文件包含英文字母的数字和字母
- javascript - 从输入类型“文件”获取文件并使用 jquery 移动到特定文件夹(不使用表单标签和提交按钮)
- facebook - 将 Cordova 原生 Facebook 插件用于 Ionic 应用程序和 DRF 服务器与 python-social-auth
- javascript - 添加异步等待而无需修改父调用函数