Invoke Sub Scripts
You can also invoke multiple sub scripts from a single executable by using $Executable in your powershell script which stores the path for powershell executable.
Test
Create directory structure like this.
app.ps1 # main psscript
resources/
setup.ps1 # sub script 1
clean.ps1 # sub script 2
Contents of scripts.
function resource_path([string]$resourcefile) {
Join-Path $PSScriptTempRoot $resourcefile
}
Write-Output "Launching Up..."
$resourcefileSetup = resource_path("resources/setup.ps1")
$resourcefileClean = resource_path("resources/clean.ps1")
. $resourcefileSetup -Id "1.2.3"
. $resourcefileClean
param($Id)
Write-Output "$Id Setting Up..."
Write-Output "Cleaning Up..."
Now compress this resources directory to a zip file and build the executable.
psburn create app.ps1 --embed-resources
psburn build app.ps1 app.cs -r resources.zip
Now if you run compiled executable, you will see this output.
Launching Up...
1.2.3 Setting Up...
Cleaning Up...