Building an exe with Powershell Studio 2019 now causes errors

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 SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
jeffrey.sikorski@compucom.com
Posts: 3
Joined: Fri Dec 18, 2015 12:49 pm

Building an exe with Powershell Studio 2019 now causes errors

Post by jeffrey.sikorski@compucom.com » Wed Jul 03, 2019 6:44 am

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.165
OS: Windows 10 Pro (64 Bit)
Build: v10.0.17134.0

I have a script that I have been building into an exe with Powershell Studio 2017
The script runs without errors and the exe that was build runs without errors

When I upgraded to 2019, the exe gets built from the same ps1 without errors BUT when I run the exe it now errors out. Below is the error I get form the command prompt while executing.

Code: Select all

Line 5: At line:4 char:1
+ [CmdletBinding(ConfirmImpact = 'Medium',
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute 'CmdletBinding'.

At line:6 char:1
+ param
+ ~~~~~
Unexpected token 'param' in expression or statement.
I have checked the code and do not see any issues and this code works with PSS 2017. Here is the code (lines 1 to 11) where the errors are occurring:

Code: Select all

[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
param
(
[Parameter(HelpMessage = 'Path to XML Configuration File')]
[ValidatePattern('.xml$')]
[ValidateScript({ Test-Path -Path $_ -PathType Leaf })]
[string]$Config,
[Parameter(HelpMessage = 'URI to Webservice')]
[string]$Webservice
)Codebox]

Any help would be appreciated to get the exe working again on 2019.
Thanks

User avatar
Olga_B
Site Admin
Posts: 117
Joined: Mon May 15, 2017 9:06 am

Re: Building an exe with Powershell Studio 2019 now causes errors

Post by Olga_B » Wed Jul 03, 2019 7:53 am

Hello,

Could you check what encoding your script has.
Change the encoding to UTF-8-BOM

User avatar
Alexander Riedel
Posts: 7001
Joined: Tue May 29, 2007 4:43 pm

Re: Building an exe with Powershell Studio 2019 now causes errors

Post by Alexander Riedel » Wed Jul 03, 2019 8:23 am

Please indicate also which engine, version, platform etc you package for.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
jeffrey.sikorski@compucom.com
Posts: 3
Joined: Fri Dec 18, 2015 12:49 pm

Re: Building an exe with Powershell Studio 2019 now causes errors

Post by jeffrey.sikorski@compucom.com » Fri Jul 05, 2019 5:55 am

I use the exe on Windows devices from win7 onward. It is 64bit only. They will have at least PS version 5.

It looks like changing the encoding to UTF-8-BOM fixed the issue.

User avatar
jeffrey.sikorski@compucom.com
Posts: 3
Joined: Fri Dec 18, 2015 12:49 pm

Re: Building an exe with Powershell Studio 2019 now causes errors

Post by jeffrey.sikorski@compucom.com » Mon Jul 08, 2019 5:24 am

jeffrey.sikorski@compucom.com wrote:
Fri Jul 05, 2019 5:55 am
It looks like changing the encoding to UTF-8-BOM fixed the issue.
Actually, it did not fix the issue. I still get the same error. I think I got a false positive by running the wrong exe. But it is a couple of days later and no matter what encoding I choose or build options I keep getting the same error as before.

User avatar
Alexander Riedel
Posts: 7001
Joined: Tue May 29, 2007 4:43 pm

Re: Building an exe with Powershell Studio 2019 now causes errors

Post by Alexander Riedel » Mon Jul 08, 2019 6:09 am

It's caused the code injection to set $PSScriptRoot correctly in packaged code.
It will be fixed in the next service build.
You can leave out the Cmletbinding statement, if possible, and it will package correctly.
Alexander Riedel
SAPIEN Technologies, Inc.