To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build: PowerShell Studio 2017 v5.4.145
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64
I have built a Windows form project that includes some module files that I have also built. The project contains .psf, .psm1 and .psd1 files. The application runs just fine in Powershell Studio. I am attempting to package the application in to an exe and I notice that the modules and their functions are not being included in to the outputted exe. I have the following settings for my build settings:
Target: Microsoft Windows 64 Bit
Script Engine: SAPIEN PowerShell V5 Host (Windows Forms)
Use STA Mode: Checked
Resolve and include external scripts: Checked
Generate .config file: Unchecked
Execution Restrictions, Operating Systems: Windows 10, Checked
I can provide screenshots of all build settings if needed but they are either blank or defaults
I also notice that in my project I cannot edit the module properties, specifically the Build setting. On all my module files the setting is "Exclude" and is greyed out or otherwise un-editable. Shared is also set to "False". I am sure this is the source of the issue but I do not know how to modify those properties of my module file.
EXE Build not including module files
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.
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.
Re: EXE Build not including module files
I moved the "Import-Module ...." lines from Globals.ps1 to Startup.pss and that seemed to do the trick.
Re: EXE Build not including module files
Yes, loading the modules in the Startup.pss / Main function is the recommend method.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: EXE Build not including module files
Note: The execution of Globals.ps1 is not guaranteed to run before executing the code of the other files.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: EXE Build not including module files
While I thought I had this problem resolved... it appears I still do not.
Do I need to copy the module files to the folder the generated .exe is located? For example:
Also, why can I not change the properties of the file, specifically the Build property? What prevents me from changing that property?
Do I need to copy the module files to the folder the generated .exe is located? For example:
Code: Select all
App folder
|_ App.exe
|_ modules
|_ module1.psm1
|_ module2.psm1
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: EXE Build not including module files
Module files are never included in a generated executable. It basically goes against the idea of a module. A module is code shared for multiple applications, akin to a dll.
If you want to re-use code between projects AND include that code inside the executable file, put the functions in simple .ps1 files and dot source them from your script. If you check the option "Resolve and include external scripts", dot sourced script will be inserted at the location of the statement before packaging.
If you want to re-use code between projects AND include that code inside the executable file, put the functions in simple .ps1 files and dot source them from your script. If you check the option "Resolve and include external scripts", dot sourced script will be inserted at the location of the statement before packaging.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.