Задача Powershell в Vs Code - Невозможно загрузить модуль в задачу VS Code - PullRequest
0 голосов
/ 08 октября 2019

У меня есть задача - и она работает, если я добавлю команду Powershell в Get-Location в команду:

{
    // 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, но не тогда, когда я запускаю его как задачу?

Примечание: я в MacOs

...