Page 1 of 1

Automated Package Build

Posted: Sat Jun 06, 2020 12:17 am
by Nillth
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: Sat Jun 06, 2020 8:30 am
by Alexander Riedel
At the moment, no. Because PSBuild needs a complete, exported .ps1 file of the project, and that currently can only be created from within PowerShell Studio.
I do know that the team is working on a mechanism to do what you ask, but I do not know the state of that.
Maybe on Monday, when the team is back, someone can fill in the current state here.

Re: Automated Package Build

Posted: Mon Jun 08, 2020 4:33 pm
by Nillth
Happy to be a tester if you need!

Re: Automated Package Build

Posted: Wed Jun 10, 2020 5:36 pm
by Nillth
Any further updates on this?
Alexander Riedel wrote: Sat Jun 06, 2020 8:30 am Maybe on Monday, when the team is back, someone can fill in the current state here.

Re: Automated Package Build

Posted: Thu Jun 11, 2020 11:36 am
by brittneyr
It is the plan to add the ability to export psf files and projects from the command line in one of the next service builds. If I get more information, I'll update you.