F5 on a saved script isn't dot sourcing
See original GitHub issuePrerequisites
- 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 am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
Summary
Looks like we’re creating a new scope for invocation of script files, leaving any set variables and functions no longer accessible.
PowerShell Version
Name Value
---- -----
PSVersion 7.2.0-preview.10
PSEdition Core
GitCommitId 7.2.0-preview.10
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
1.60.0
e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
x64
Extension Version
ms-vscode.powershell-preview@2021.11.1
Steps to Reproduce
- New file
- Add
$a = 50
- Save it
- <kbd>F5</kbd>
- Type
$a
in the PSIC - See it’s not set
Visuals
No response
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Determine if PowerShell script has been dot-sourced
When you run a script from Visual Studio Code or the PowerShell ISE with Debug > Run/Continue ( F5 ), it is implicitly...
Read more >Troubleshooting - F5 BIG-IP AS3
When sending a large declaration with hundreds of application services, you may experience a 500 error stating that the save sys config operation...
Read more >Dot sourcing in powershell - Microsoft Q&A
Dot sourcing in powershell. Hi I have two ps1 files in a path C:\Users\myname\Documents\Files\P.ps1. I am trying to call a function 'launch' ...
Read more >Display and search all variables of a PowerShell script with ...
If you then call the function dot sourced on the console, the variables are available in the Global scope. This procedure might not...
Read more >Script File - an overview | ScienceDirect Topics
3.6 Script Files. A script file is an m-file that contains a sequence of instructions but is not a function. Unlike a function,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Probably an oversight. Moving away from dot-sourcing in the API is done for constrained language mode compatibility. In this case (if I’ve read correctly) that doesn’t make sense because the debugger isn’t going to work in CLM. Just remember that anything that dot-sources or uses
useLocalScope: false
(the default setting) will fail in CLM.I feel like I called this out earlier that it was using
&
instead of.
in the code.