Page 1 of 1

Automated Package Build

Posted: Thu Nov 05, 2020 7:25 pm
by Nillth
Follow on from this Locked Topic:
viewtopic.php?f=12&t=14825&p=77932#p77932

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.178
OS: Windows 10 Pro (64 Bit)
Build: v10.0.19635.0

Is there any way to automate the building of a psproj file?

e.g. the following will build a exe based off of a ps1 file using the psbuild config.

Code: Select all

"C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2020\PSBuild.exe" /Package "C:\PathTo\Test-Project\TestProject.ps1.psbuild"
however when attempting to build a project the exe fails.

Code: Select all

"C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2020\PSBuild.exe" /Package "C:\PathTo\Test-Project\TestProject.psproj.psbuild"
I can see that when PowerShell Studio builds a package from a Project, it first creates a consolidated package.. *.package.ps1 then uses that for the PSBuild Process.

Code: Select all

"C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2020\PSBuild.exe" /Package "C:\PathTo\Test-Project\TestProject.package.ps1.psbuild"
Is there anyway to build a psproj from cmdline? or does it have to go via the Gui?
As the only way I have figured out how to do it so far is kinda ugly...

Code: Select all

$PSStudio = "C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2020\PowerShell Studio.exe";
$WshShell = New-Object -ComObject WScript.Shell

$ProjectFile = $(Get-ChildItem -Filter "*.psproj").FullName
$ProjectStartupFile = $(Get-ChildItem -Filter "Startup.pss").FullName;

$SPSProc = Start-Process -PassThru -FilePath $PSStudio -ArgumentList $ProjectFile 

Write-Log "Started Process ID: $($SPSProc.Id)"
Start-Sleep -Seconds 30
& $PSStudio $ProjectStartupFile
Start-Sleep -Seconds 1

Write-Log "Activate Application"
While (!($WshShell.AppActivate($SPSProc.Id))) { Start-Sleep -Seconds 1 }

Write-Log "Start Build"
$WshShell.SendKeys("^{F7}")
Write-Log "Get PSBuild"
$PSBuild = $null
While ($null -eq $PSBuild){
$PSBuild = Get-Process -Name PSBuild -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 500
}
Write-Log "Got Build"
$PSBuild.WaitForExit()
Write-Log "PSBuild Complete"
While (!($WshShell.AppActivate($SPSProc.Id))) { Start-Sleep -Seconds 1 }
Write-Log "Exit Application"
$WshShell.SendKeys("%{F4}")
Write-Log "Finished"

Re: Automated Package Build

Posted: Tue Nov 10, 2020 11:23 am
by brittneyr
With the latest service release (5.7.182), there is no way to build from the command line.

As we have now received multiple requests for this, we are working on a solution to build a project or form from the command line. This should be included in the next service release of PowerShell Studio.

Re: Automated Package Build

Posted: Sun Nov 15, 2020 11:01 pm
by Nillth
Not that I am excided to see this functionality....

:)
SAPIEN_Updates_fVUYKar0JO.png
SAPIEN_Updates_fVUYKar0JO.png (23.44 KiB) Viewed 8622 times