microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.76k stars 29.1k forks source link

Push-Location and relative referencing not working correct #225376

Open OlafDrechsler opened 2 months ago

OlafDrechsler commented 2 months ago

Type: Bug

The situation: We're building something in Powershell 7. All the script files are in C:\TomsTool\PS with icons in subfolder C:\TomsTool\PS\Icons

The problem: I run the file C:\TomsTool\PS\Show-Menu.ps1 in debug mode in VS Code. In that script we use Push-Location to set the path to C:\TomsTool\PS Retrieving the value with Get-Location prooves that Push-Location worked correct. Nevertheless relative referencing to a file Icon = '.\Icons\somepic.ico'; refers to my home path and results in an error:

Line |
 241 |      $formMenu = [Form]@{Text='Verarbeitung';
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot create object of type "System.Windows.Forms.Form". Cannot convert value ".\Icons\somepic.ico" to type
     | "System.Drawing.Icon". Error: "Could not find a part of the path 'C:\Users\OlafDrechsler\Icons\somepic.ico'."

The reason: I did open the script file by double clicking in Microsoft Explorer and straight away started run in debug mode in VS Code. The error does not happen when I open VS code, open the folder C:\TomsTool\PS from within VS Code and open the script file from within VS Code.

My humble opinion: I think Push-Location should work the same way in both situations.

VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:34:26.404Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz (8 x 1498)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.74GB (5.90GB free)| |Process Argv|C:\\TomsTool\\PS\\Show-Menu.ps1 --crash-reporter-id a8ea1613-c3b4-4026-a435-3572160607d0| |Screen Reader|no| |VM|0%|
Extensions (1) Extension|Author (truncated)|Version ---|---|--- powershell|ms-|2024.2.2
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 vscrp:30673768 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 0ee40948:31013168 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 newcmakeconfigv2:31071590 impr_priority:31102340 nativerepl1:31104043 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-t:31111718 wkspc-ranged-t:31111713 ```
vs-code-engineering[bot] commented 2 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.92.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

OlafDrechsler commented 2 months ago

still the same behavior