Why does “F5 - Start Debugging” ignore breakpoints in PowerGUI?

て烟熏妆下的殇ゞ 提交于 2019-12-12 16:09:47

问题


I'm not sure if I'm being a bit thick, but I have a simple script with three lines:

$iis = 90000
$name = "somesite"
Write-Host("Values are: $iis and $name")

If I set a breakpoint on any of these lines and hit the play button (F5 - start debugging) the script runs but the breakpoints are ignored.

If I start the script with F11 (step into) I can step through just fine, however hitting F5 to run to the next breakpoint again causes PowerGUI to ignore the breakpoints

The script I'm working on is substantial and I don't really want to have to F11 through every line of code.

Why would this be?

  • I'm running PowerGUI 2.2.0.1358 on Windows 7 64-bit Ultimate Edition.
  • I tried both the x64 and x32 versions of the PowerGUI script editor without success.
  • I'm also running the PowerGUI Script Editor as Administrator (launched using right-click on PowerGUI Script Editor shortcut and Run As Administrator)
  • My PowerShell execution policy is set to Unrestricted.

回答1:


It looks like there's a problem with PowerShell and square brackets in folder and filenames.

Both PowerGUI and PowerShell ISE won't hit breakpoint if the script being debugged resides in a folder with [ or ] in the name.




回答2:


I had this problem when the script that I was running was on a remote file share. E.g. \\serverA\FileShare\script.ps1.

When I saved the script as c:\script\script.ps1 it was ok.




回答3:


Powershell apparently also has an issue with spaces in the folder names. It did not like 'My Documents' but did for 'Documents'. Once I switched my path in PowerShell within ISE the debugger worked again.



来源:https://stackoverflow.com/questions/4368348/why-does-f5-start-debugging-ignore-breakpoints-in-powergui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!