Compile to Exe with Sub Folder included

Is it somehow possible, to include Subfolders to an EXE File?
Because i have an Project where i have several “Sub Scripts” which has some Logic in it and I would like to have those on the EXE it self.

If you enable the bundling function of the packager it will automatically include any scripts that you dot source into the main script.

Im using the Following Powershell to include my Sub Scripts:
. (Join-Path -Path $PSScriptRoot -ChildPath "\Data\create-Support-Entry.ps1")

after that i have my Function called from the Powershell File.
Create-Support-Entry

I have let the Bundle settings by Default:
Bundle = @{

            Enabled = $true

            Modules = $true

            # IgnoredModules = @()

        }

After Compiling i get the following Error Message on my Powershell Window:

. : The term 'G:\Documents\WindowsPowerShell\Scripts\Support Documentation\out\Data\create-SQL-Connection.ps1' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:99 char:7
+     . (Join-Path -Path $PoshToolsRoot -ChildPath "\Data\create-SQL-Co ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (G:\Documents\Wi...-Connection.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

. : The term 'G:\Documents\WindowsPowerShell\Scripts\Support Documentation\out\Data\select-SQL-Entrys.ps1' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:100 char:7
+     . (Join-Path -Path $PoshToolsRoot -ChildPath "\Data\select-SQL-En ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (G:\Documents\Wi...-SQL-Entrys.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Is there an better way to do that?

Hmmmm that seems correct. It may be a bug in PoshTools. You can try a couple different ways of include the file:

. (Join-Path $PSScriptRoot "\Data\create-Support-Entry.ps1")

Or maybe

. "$PSScriptRoot\Data\create-Support-Entry.ps1"

I will have to see why this isn’t working.

So I have used:

. “$PSScriptRoot\Data\create-Support-Entry.ps1”

and that was working fine.
The Scripts got bundle up into the Exe File.
Maybe there is really something strange with . (Join-Path)

BR
Stefan

1 Like