Vs Code任务中的Powershell-无法将模块加载到VS Code任务中

时间:2019-10-08 14:28:44

标签: powershell visual-studio-code vscode-tasks

我有一个任务-如果我在命令中的Get-Location中放置Powershell命令,该任务将起作用:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "osx": {
        "options": {
            "shell": {
                "executable": "/usr/local/bin/pwsh",
                "args": [
                    "-NoProfile",
                    "-Command"
                ]
            }
        }
    },
    "tasks": [
        {
            "label": "generate proto",
            "type": "shell",
            "command": "Get-Location",
            "problemMatcher": []
        }
    ]
}

如果我使用自定义功能,则无法使用:

...
"command": "Get-MyCommand",
...

错误:

is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

好吧,这是因为未加载模块。 我的个人资料中有Import-Module <path>.psm1

.config/powershell/Microsoft.VSCode_profile.ps1

然后它可以在Powershell集成终端中运行,但是当我将其作为任务运行时却不能运行?

注意:我在MacO上

0 个答案:

没有答案