PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.71k stars 491 forks source link

Script launch configuration with .psm1 #2308

Closed JVimes closed 4 years ago

JVimes commented 4 years ago

Issue Description

I wrote CIBuildUtils.psm1 and want to debug it's Invoke-Build function. I expected I could with this in Launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Build launch",
            "type": "PowerShell",
            "request": "launch",
            "script": "ipmo -force ${workspaceFolder}\\CIBuildUtils.psm1; Invoke-Build",
            "cwd": "${workspaceFolder}"
        },
    ]
}

But when I hit F5 on that .psm1 file, I get:

PS> c:\Users\user\OneDrive\Work Documents\user\CIBuildUtils\CIBuildUtils.psm1

    Cannot run a document in the middle of a pipeline: C:\Users\user\OneDrive\Work Documents\user\CIBuildUtils\CIBuildUtils.psm1.
At line:0 char:0
PS>

Attached Logs

DebugAdapter.log EditorServices.log Start-EditorServices-EditorServices.log vscode-powershell.log

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18362
VSCode 1.40.1
PowerShell Extension Version 2019.11.0

PowerShell Information

Name Value
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.18362.145
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand) |Extension|Author|Version| |---|---|---| |code-spell-checker|streetsidesoftware|1.7.20| |csharp|ms-vscode|1.21.7| |git-graph|mhutchie|1.18.0| |markdown-all-in-one|yzhang|2.5.1| |powershell-preview|ms-vscode|2019.11.0| |prettier-plus|svipas|3.4.0| |vscode-docker|ms-azuretools|0.8.2| |vscode-graphql|Prisma|0.2.2| |xml|DotJoshJohnson|2.5.0|
JVimes commented 4 years ago

Just realized "script" isn't an in-line script. Closing.