请注意,在我的 VS Code 中,一个新的终端,第一行表明它已正确默认为 Powershell 7.2.2 - 正如我认为应该的那样。
但在同一张屏幕截图中,我运行的第一个脚本(其中有一个打印 powershell 版本的命令)显示 PSVersion
是 5.1.19041.1320
这是来自 settings.json
的所有 powershell 特定 VSCode 条目
"terminal.integrated.profiles.windows": {
"MyPowerShell_7": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": ["-NoProfile"]
}
},
"terminal.integrated.defaultProfile.windows": "MyPowerShell_7",
"powershell.powerShellAdditionalExePaths": [
{
"exePath": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"versionName": "MyPowerShell_7"
}
],
"powershell.powerShellDefaultVersion": "MyPowerShell_7",
为什么运行 Test-Json
cmdlet 这么困难?
最佳答案
关于visual-studio-code - 默认 Powershell 终端为 7.2,但脚本以 Powershell 5.1 运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71769124/