Questions about bundling modules in compiled exe

Hello everybody,

edit: First of all i am really sorry for wrong formatted code, actually i do not know how i can format it :frowning:

i have a (maybe small) comprehension problem with the following:

I try to compile a powershell script with visual studio code. I also have a function in another .psm1 file, and i also tried to put this function inside another .ps1 file.

everytime i compile the script and run, i get the following error message:

the original module was expected as .ps1 file in the path… I thougt bundling insert the module file in the exe and is also compiled…

My code is really really simple, because it is just a test project to test the bundling:

#. (Join-Path -Path $PSScriptRoot "script2.ps1")
Import-Module ($PSScriptRoot + "\script2.ps1")

and here is my relevant part of package.psd content:

            Bundle = @{
                Enabled = $true
                Modules = $true
                # IgnoredModules = @()

Can anyone give me the right hint where my mistake is, please?

edit: used version of powershell pro tools vs code extension is: v5.21.1

Best regards

this worked now:

. "$PSScriptRoot\script2.ps1"

any idea why import-module does not work?

And maybe any idea for that case:
i want to bundle all .ps1 files in exe from a specified folder .

My examle works, but not in my compiled exe:

Get-ChildItem -path "$PSScriptRoot\test\" -Filter  "*.ps1" | ForEach-Object {
    . $_
get-writer "blavla"

The bundler uses static code analysis to determine which files to bundle. The import module example seems like a bug in the bundler as I would expect that to work. The Get-ChildItem example will not work because the bundler will not execute that code so it won’t be able to determine the files to bundle.