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 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 4 years and 8 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
jscompucom
Posts: 3
Last visit: Thu Aug 26, 2021 6:09 am

Building an exe with Powershell Studio 2019 now causes errors

Post by jscompucom »

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.
  1. Line 5: At line:4 char:1
  2. + [CmdletBinding(ConfirmImpact = 'Medium',
  3. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Unexpected attribute 'CmdletBinding'.
  5.  
  6. At line:6 char:1
  7. + param
  8. + ~~~~~
  9. 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: 196
Last visit: Thu Mar 28, 2024 8:34 am

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

Post by Olga_B »

Hello,

Could you check what encoding your script has.
Change the encoding to UTF-8-BOM
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

Please indicate also which engine, version, platform etc you package for.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jscompucom
Posts: 3
Last visit: Thu Aug 26, 2021 6:09 am

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

Post by jscompucom »

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
jscompucom
Posts: 3
Last visit: Thu Aug 26, 2021 6:09 am

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

Post by jscompucom »

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: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

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.
This topic is 4 years and 8 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.