Debug with multiple files not working

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 2
Joined: Fri Mar 27, 2015 10:23 am

Debug with multiple files not working

Post by VCPIeng » Tue Mar 22, 2016 5:44 pm

Product, version and build: PowerShell Studio 2016 [REMOVED BY MODERATOR]
32 or 64 bit version of product: 64
Operating system: Windows 7
32 or 64 bit OS: 64

I am trying to debug multiple files without success.
I have:
- A main file, with parameters and no functions
- 2 accessory files, with multiple functions (each function has parameters).

The main file dot sources the accessory files at the beginning and calls the functions as needed.
Now, everything works fine and dandy when I debug one file at a time.. as it prompts me for the parameters.
The issue arises if I try to debug all of them together. it never prompts for the parameters and quits the debug immediately.
Any ideas?

UPDATE: I found a way to run the main file in multi-file debug by using the call function in the project startup file Startup.pss:
Call-mainfile_ps1 -param1 "string1" -param2 "string2". So the main file runs and debugs.
The problem is that when it calls the dot sourced functions, it doesn't switch file to let me debug those functions - it just runs them and goes to the next breakpoint in the main file.
Of course the accessory files all have their breakpoints.

User avatar
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Debug with multiple files not working

Post by davidc » Wed Mar 23, 2016 8:12 am

For your own protection, please do not post your subscription number on the forums.

I'm assuming you are working in a project?

If you are working with a project and are dot sourcing ps1 files, make sure you mark the file's Build setting to Content.

1. Select the file in the project panel:
Project Pane.png
Project Pane.png (10.06 KiB) Viewed 719 times
2. Then set the Build property in the Property Panel:
Project File Build.png
Project File Build.png (10.36 KiB) Viewed 719 times
The file will no longer have a Call- function associated with the file and it will remain as is. Then you can debug the project using the normal Debug command instead of Debug with Multiple files command.

SAPIEN Technologies, Inc.

User avatar
Posts: 2
Joined: Fri Mar 27, 2015 10:23 am

Re: Debug with multiple files not working

Post by VCPIeng » Wed Mar 23, 2016 12:01 pm

YES!! YES!!!!

You don't know how much headache this saves me in debugging, as I kep calling functions back and forth between files.

Many thanks.