PowerShell executable for PS V7

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 1 year and 4 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
waynecierkowski
Posts: 28
Last visit: Mon Jul 10, 2023 10:51 am

PowerShell executable for PS V7

Post by waynecierkowski »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
Operating system: Server 2012 R2
PowerShell version(s): 7.2.7

*** Please add details and screenshots as needed below. ***

I considering converting my PS 5.1 executable programs to PS 7.2.7. I installed PS 7 on my test server, .NET 6.0 and the Powershell 7 Runtime Package for PowerShell 7.2.6 x64 Runtime.exe.

Normally when I made changes to a program I would just build the executable and copy over the exe file over to the server that it executes on. Also the executable when built is placed in the BIN folder.

So to test I took a program that is run multiples time a day and changed the settings in the Package Build Settings to specify Script engine of Sapien PowerShell 7.2.6 Host (Command Line). Now when I build my program it ends up in a separate folder under the Bin folder and not only is the EXE file there but additional 23 "supporting" files. I called them "Supporting" because just coping over the EXE file to the server it would not run. After coping over the 23 "Supporting" files my program runs as it should.

What am I doing wrong? I would prefer after I do a Package Build for an executable I end up with just a Executable that can be copied over to a server and would be able to execute it.

I also noticed that these "supporting" files are specific to that script/program and not generic. I tried doing a simple "Hello World" program and place the built EXE file in the same folder as my first one and it would not run. I had to copy over the entire output folder for that program over to my server.

So that means if I wanted to convert 6, 12 programs to PS 7.2.7, on my server I would have 6-12 different subfolders under the folder that now contains all of my executable files for PS 5.1. That would mean all the schedules that execute my programs would need to be changed to reflect where to execute the program. We use a Enterprise Scheduler Package to do all of our work in the company.

How can I get an executable file for a script that was written for PS 7.2.7 that can be moved over to a server to run with out all of those supporting files?

TIA..
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell executable for PS V7

Post by Alexander Riedel »

If you package for 7.2.7 you would need either PowerShell 7.2.7 installed on the target machine OR the 7.2.7 runtime. The version numbers must match. We have not released the 7.2.7 runtime yet, that is still in the process. You need the .NET 6 desktop runtime as well as you pointed out.

The newer .NET runtimes work differently than the .NET Framework PowerShell 5.1 is built on. Think of your application as a folder rather than a file.
Microsoft .NET 3.0 and above requires a good number of files in a folder for an application to run. It is how the underlying architecture works.
We know that this a shift in how things operate and we have to deal with that just as well for each minor PowerShell release.

Generally we recommend making an MSI installer for packaged applications. It is an extra step, I know, but it makes managing versions and updating them easier.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
waynecierkowski
Posts: 28
Last visit: Mon Jul 10, 2023 10:51 am

Re: PowerShell executable for PS V7

Post by waynecierkowski »

Thanks for the response.

Do you have some documentation on how to create a MSI installer?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell executable for PS V7

Post by Alexander Riedel »

There are a number of articles here: https://www.sapien.com/blog/?s=MSI
There are some changes here and there in the software, but that should be easy enough to adapt.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 4 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.