question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"script" configuration in launch.json behavior no longer runs a cmdlet.

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

I have been using a launch.json configuration for a couple years to run my active script in a new, external PowerShell window. Recently, this has broken. It’s obvious from the text in the console that the working folder is being stuck onto the front of the value in the “script” setting as though it assumes the value is a .ps1 file in the local folder instead of a cmdlet that’s been working forever.

This is the configuration section: { “name”: “Run in External PowerShell Window - v5”, “type”: “PowerShell”, “request”: “launch”, “script”: “Start-Process”, “args”: [ “-FilePath ($Env:SystemRoot + ‘\system32\WindowsPowerShell\v1.0\powershell.exe’)”, “-Argumentlist ‘-NoExit -ExecutionPolicy Bypass -File "${file}"’” ], “cwd”: “${file}” },

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.1151
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1151
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.60.0
e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
x64

Extension Version

ms-vscode.powershell@2021.8.2

Steps to Reproduce

  • Create a PowerShell script to do something simple such as running Get-Process.

  • Save it into a folder.

  • Open the folder in VS Code .

  • Create a launch.json configuration with these settings: { “version”: “0.2.0”, “configurations”: [ { “name”: “PowerShell: Launch Current File”, “type”: “PowerShell”, “request”: “launch”, “script”: “${file}”, “cwd”: “${file}” }, { “name”: “Run in External PowerShell Window - v5”, “type”: “PowerShell”, “request”: “launch”, “script”: “Start-Process”, “args”: [ “-FilePath ($Env:SystemRoot + ‘\system32\WindowsPowerShell\v1.0\powershell.exe’)”, “-Argumentlist ‘-NoExit -ExecutionPolicy Bypass -File "${file}"’” ], “cwd”: “${file}” } ] }

  • Go to the debugging panel and select the option for “Run in External PowerShell Window - v5”.

  • Hit F5.

  • Look in the terminal window for the error.

Visuals

No response

Logs

I tried setting logging to Diagnostic and to Verbose, but no log folder was created beneath $HOME.vscode\extensions.ms-vscode.powershell-1.9.0. I suspect this may be because I’m trying to launch in an external window.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
KevinLeeBuchancommented, Sep 10, 2021

I have tested it on two different machines, across four different configurations that rely on the same capability and all were successful. Thank you.

Closing bug report.

1reaction
KevinLeeBuchancommented, Sep 9, 2021

So sorry… can you link me to instructions to install the preview of the extension? I’d love to test it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure launch.json for C/C++ debugging in Visual Studio ...
A launch.json file is used to configure the debugger in Visual Studio Code. ... For attach , this parameter does not change the...
Read more >
VSCode Unable to Recognise default "program" in launch.json
In VSCode, click Debug or Ctrl + Shift + D , then press F5 · Select . · No task runner configured ·...
Read more >
Visual studio code cmd error: Cannot be loaded because ...
1. Press the windows-button on your keyboard. 2. Type 'PowerShell' 3. Right-click Windows PowerShell 4. Click Run as Administrator 5.
Read more >
Using Visual Studio Code for PowerShell Development
Visual Studio Code (VS Code) is a cross-platform script editor by Microsoft. ... However, it's no longer in active feature development.
Read more >
Debugging - vscode-docs
To debug your app in VS Code, you'll first need to set up your launch configuration file - launch.json . Click on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found