Unable to package and run with custom modules

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
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
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.
This topic is 2 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
trevor530
Posts: 25
Last visit: Mon Feb 12, 2024 9:27 am

Unable to package and run with custom modules

Post by trevor530 »

Product: PowerShell Studio 2021 (64 Bit)
Build: v5.8.187
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19042.0
PowerShell version(s): 5

I am having an issue packaging and running a script application. It worked in previous builds of Powershell Studio. I should start by saying that the script, a Windows Forms app, runs just fine in the editor. My modules are imported and everything just runs. I have "resolve and include external scripts" checked in my Output Settings. There used to be a way to manually include files in a package, at least I thought there was, maybe I am wrong. How do I package an .exe and create an .msi when I have ./modules to include?

My project directory has all the scripts that make up the app in the main project folder and the modules it uses in a modules folder in the main project folder.
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 1:15 am
Answers: 19
Been upvoted: 37 times

Re: Unable to package and run with custom modules

Post by Alexander Riedel »

Modules cannot be included in an exe, that goes counter to the idea of a module. Dot sourced scripts of course are a different story.
From your description you would just need to include the modules folder in your MSI. On the Files and Folders tab you would need to add your modules folder.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
trevor530
Posts: 25
Last visit: Mon Feb 12, 2024 9:27 am

Re: Unable to package and run with custom modules

Post by trevor530 »

Maybe this is the wrong thread but I had the impression (falsely?) that Modules were like libraries. I use/reference these modules in other scripts. Often I just copy the modules to a new script and start building. I am actually currently reading about setting up a Module Repository in my organization and also just generally reading up on the proper use of modules.

Would/Does it make sense to have an .exe import/install those modules from a central repository or am I better served just changing them from a .psm1 file to a .ps1 file and Dot sourcing them and doing that in all my other scripts?
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 1:15 am
Answers: 19
Been upvoted: 37 times

Re: Unable to package and run with custom modules

Post by Alexander Riedel »

"Libraries" is just as much of a loose term as "Modules" :D
I am actually working on a blog post attempting to explain the differences between using modules and dot sourcing.
If you don't need to change it right now this minute, would be able to wait for that another few days?
If not, the basic rule in my opinion is, if this is your own private affair and no on else is using this, dot source the files.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
trevor530
Posts: 25
Last visit: Mon Feb 12, 2024 9:27 am

Re: Unable to package and run with custom modules

Post by trevor530 »

I can totally wait a few days! I need to add the Sapien blog to my RSS feed :-)
User avatar
Alexander Riedel
Posts: 8473
Last visit: Tue Mar 19, 2024 1:15 am
Answers: 19
Been upvoted: 37 times

Re: Unable to package and run with custom modules

Post by Alexander Riedel »

Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 2 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.