Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
KevinLeeBuchan opened this issue Sep 9, 2021 · 5 comments
Closed
4 tasks done
Labels
Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@KevinLeeBuchan
Copy link

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

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.

@KevinLeeBuchan KevinLeeBuchan added the Issue-Bug A bug to squash. label Sep 9, 2021
@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 9, 2021
@andyleejordan
Copy link
Member

Duplicate of #3537 and (fortunately) already resolved, the fix is available in the PowerShell Preview extension. Can you confirm it works for you? I'm about to roll it into stable today.

@andyleejordan andyleejordan added Needs: Fix Verification Please verify the fix for us! Resolution-Duplicate Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Sep 9, 2021
@KevinLeeBuchan
Copy link
Author

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 9, 2021
@andyleejordan
Copy link
Member

andyleejordan commented Sep 9, 2021

@KevinLeeBuchan In the VS Code marketplace, search for "PowerShell." Disable the "PowerShell" extension, reload, then install the "PowerShell Preview" extension (with the pretty colored icon) and reload.

image

@andyleejordan
Copy link
Member

That fix is now in the just-updated stable extension!

@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 9, 2021
@KevinLeeBuchan
Copy link
Author

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 10, 2021
@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Fix Verification Please verify the fix for us! Needs: Maintainer Attention Maintainer attention needed! Resolution-Duplicate Will close automatically. labels Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
None yet
Development

No branches or pull requests

2 participants