psbuild does not build a working .exe file.

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
bproscia
Posts: 5
Last visit: Mon Jul 15, 2019 5:33 am

psbuild does not build a working .exe file.

Post by bproscia »

PowerShell Studio 2018 v5.5.152
64 bit version of product:
Operating system:
64 bit OS:

The .exe produced by running the Packager from PowerShell Studio 2018 works correctly.
When using the command line tool 'psbuild' with the /PACKAGE option the .exe produced does not work.
The error displayed suggests that the .ps1 files that contain the required functions are not in the .exe.
Again, this works fine when packaged from PowerShell Studio GUI. We need the command line to work for our automated
build environment.

The output from PowershellStudio when it works: (I altered the names of our actual files.)
>> Package 'C:\GIT\tools\test.psproj'
>> Building (test) Project...
>> Merging 'Startup.pss' ...
>> Merging 'file1.ps1' ...
>> Merging 'file2.ps1' ...
>> Merging 'file3.ps1' ...
>> Merging 'file4.ps1' ...
>> Merging 'file5.ps1' ...
>> Merging 'file6.ps1' ...
>> Merging 'file7.ps1' ...
>> Merging 'file8.ps1' ...
>> Merging 'file9.ps1' ...
>> Writing 'test.Package.ps1' ...
SAPIEN Package and Deploy Tool 4.1 (c) 2005 - 2018 SAPIEN Technologies, Inc.

------ Build started: test, Configuration: x64 ------
Packaging with SAPIEN PowerShell V5 Host (Command line) x64
Adding C:\GIT\tools\test.Package.ps1
Writing scripts to bin\x64\test.exe
Embedding default manifest...
Package completed

>> Completed

The output from the 'psbuild' command when the .exe does not work:
C:\GIT\DG\hotfix_7.4.x\dgserver\hotfix\tools\services-stop>psbuild /PACKAGE "C:\GIT\tools\test.psproj.psbuild"
SAPIEN Package and Deploy Tool 4.1 (c) 2005 - 2018 SAPIEN Technologies, Inc.

------ Build started: test, Configuration: x64 ------
Packaging with SAPIEN PowerShell V5 Host (Command line) x64
Adding C:\GIT\tools\test.psproj
Writing scripts to bin\x64\test.exe
Embedding default manifest...
Package completed

It does seem obvious that the merging of the .ps1 files that contain required functions did not occur from the command line in the
same way that it did from the GUI.

Is my project missing a build option setting in order to get the command line to work for the same project file that works in PowerShell Studio?
Is there anything else that I might be doing wrong to cause this type of problem?

Your quick response would be very much appreciated.

-Regards
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: psbuild does not build a working .exe file.

Post by davidc »

Since this is a project, you must run it from PowerShell Studio, because the script needs to be generated in order for PSBuild to package it.

Note: This also includes psf files.
David
SAPIEN Technologies, Inc.
User avatar
bproscia
Posts: 5
Last visit: Mon Jul 15, 2019 5:33 am

Re: psbuild does not build a working .exe file.

Post by bproscia »

David,

Thanks for the rapid response.

Can you suggest a different way for me to set this up so we can build an .exe from the command line?
What alternative approaches or options would you suggest? I want to be able to combine multiple .ps1 function files
and create a .exe using psbuild if at all possible. This is a requirement from our build team to be able to automate the
creation of the .exe.

Regards,
-Bob
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: psbuild does not build a working .exe file.

Post by davidc »

For the projects, there isn't a command line option at this time, but it is on our TODO list.

An alternate method would be to export the project to a ps1 file and automate the building of the exported script instead.
David
SAPIEN Technologies, Inc.
User avatar
bproscia
Posts: 5
Last visit: Mon Jul 15, 2019 5:33 am

Re: psbuild does not build a working .exe file.

Post by bproscia »

Thanks for your help so far. I'm new to Powershell Studio.
I see how to export the scripts and it produced a single .ps1 file
that contained all of the .ps1 files.
My questions are:
  • How would I take the combined .ps1 file to produce the
    .exe file that I want to deliver to our customers.
  • What type of project would I use to do that?
  • How would I use psbuild to do this for me in an automated fashion?
If you can provide an example project that would be great.

Thanks for your help.
-Regards
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: psbuild does not build a working .exe file.

Post by davidc »

To create the ps1 from a project go to Ribbon->Deploy->Export->Export to File:
Export to File.png
Export to File.png (37.18 KiB) Viewed 4315 times
Any project that is not a Collection or Module Project will work. You have to set the Build property of the project files to Include and it will merge the files into the exported script.

As for an example project, simply create a new Multi-Form project and it will merge the files into a single script when exported.
David
SAPIEN Technologies, Inc.
User avatar
bproscia
Posts: 5
Last visit: Mon Jul 15, 2019 5:33 am

Re: psbuild does not build a working .exe file.

Post by bproscia »

David,

That's the step that I knew how to do; see my previous post. How do you turn the combined .ps1 file into a .exe from the psbuild command?
I cant get that part to work.

Regards,
Bob
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: psbuild does not build a working .exe file.

Post by davidc »

Here are the steps you need to take:

1. Export the project to ps1 file.
2. Open the exported ps1 file in PowerShell Studio (Press No on all the prompts because it is an exported file)
3. Configure the Packager settings for the exported script.
4. Call PSBuild.exe and pass the exported script's psbuild file as a parameter:

Code: Select all

PSBuild  /PACKAGE "C:\GIT\tools\test.Export.ps1.psbuild"
I don't recommend editing the exported script. Always work in the project itself and export the changes.
David
SAPIEN Technologies, Inc.
User avatar
bproscia
Posts: 5
Last visit: Mon Jul 15, 2019 5:33 am

Re: psbuild does not build a working .exe file.

Post by bproscia »

David,

These were exactly the steps that I needed. I was able to create the project as you described and use the psbuild command to create the .exe that ran fine. It would be neat if you guys could combine this so that I would not have to do the export
step manually and use a different project file. Maybe a simple /PACKAGE_EXPORT command :)

Thanks for your help,much appreciated.

Regards,
Bob
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: psbuild does not build a working .exe file.

Post by davidc »

Yes, creating a more seamless approach is on our TODO list.
David
SAPIEN Technologies, Inc.
This topic is 5 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.