Primalscript 2020 and Powershell V7 problem with debugging

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.
eW_AMCIM
Posts: 3
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Wed Jan 15, 2020 5:53 am

Primalscript 2020 and Powershell V7 problem with debugging

Post by eW_AMCIM »

Product, version and build: Product: PrimalScript (64 Bit)
Build: v7.7.139
OS: Windows Server 2016 Standard (64 Bit)
Build: v10.0.14393

This version works fine with Powershell V5 (running scripts, debugging them), but I'm having some trouble with Powershell V7. I installed PS7 first, after which I upgraded to the Primalscript version above. After installing everything and opening Primalscript 2020, it was building cache for a long while.

I changed the settings in the ribbon to:

Local Machine 64 bit
PowerShell 7


When I set a breakpoint and run the script I get a *** Debug Session ended. *** error. When running the script normally (control F5 or 'Run' option of the ribbon, also in Elevated mode) I get 'Cannot instantiate PowerShell V7 object: 0'. But when I choose 'Run in shell' the script runs without any errors.

I checked the Cache Editor, found that it didn't have Cache for Powershell 7 (which suprised me considering the relatively long wait earlier) so I created it, copying them from V5. Not sure whether this was the correct thing to do. It didn't help anyway. :-D

Script Security settings:

Before I had (never changed a thing here)
Windows Powershell - 64 bit: Remote Signed for Local Machine, Current User Undefined
Windows Powershell - 32 bit: Remote Signed for Local Machine, Current User Undefined


And after installing PS7 and new version of PrimalScript 2020 this was added
Powershell 7 - 64 Bit: Remote Signed for Local Machine, Current User Undefined

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

Re: Primalscript 2020 and Powershell V7 problem with debugging

Post by Alexander Riedel »

Copy the cache may give you some intellisense when V7 is selected, but because there are some differences, it will be wrong at times, contain cmdlets that are no longer available and miss new cmdlets.
So that is not what we would advise.
Please indicate *exactly* what version of V7 you have installed ($psVersionTable) and the exact location where it is installed.
Please let us know if you have also installed any PowerShell 7 preview builds
Go to this folder "C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App"
and let us know which versions you see there.
Alexander Riedel
SAPIEN Technologies, Inc.

eW_AMCIM
Posts: 3
Joined: Wed Jan 15, 2020 5:53 am

Re: Primalscript 2020 and Powershell V7 problem with debugging

Post by eW_AMCIM »

Thanks Alexander. Because it's a (relatively new) server without access to the internet, the server was pretty clean and I installed the prerequisites myself (.NET framework 4.8 and apsnetcore 3.1.3). I used the PS7 installer from Github (PowerShell-7.0.0-win-x64.msi). Asp.net core app is version 3.1.3 (aspnetcore-runtime-3.1.3-win-x64.exe). This is what I see when I check $psVersionTable:

Code: Select all

PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.14393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
PS7 is installed in the default location: C:\Program Files\PowerShell\7\pwsh.exe

The Microsoft.WindowsDesktop.App folder only shows the *\shared\Microsoft.AspNetCore.App\3.1.3\ folder

I'm not sure what else I should have done with building the cache, didn't see any other option?

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

Re: Primalscript 2020 and Powershell V7 problem with debugging

Post by Alexander Riedel »

From what you tell me, you installed the wrong .NET Core runtime. PrimalScript is not an ASP.NET app, it is a desktop app.
The installer would include the correct runtime, but maybe without internet access Microsoft's installer gets confused as well.
Without the correct runtime, PrimalScript cannot connect to PowerShell 7. That obviously makes it impossible to build the cache or do anything else.

For the sake of anyone else reading this, the download location is here: https://dotnet.microsoft.com/download/dotnet-core/3.1
The correct runtime is "Desktop Runtime 3.1.3", which is the SECOND from the top on right hand side.
The direct link to the 64 bit installer is: https://download.visualstudio.microsoft ... in-x64.exe

Please note that the exact version of the .NET Core Framework may change over time. But it will still require the 'Desktop Runtime'. It is not necessary to install the .NET Core Runtime as it is included in the Desktop runtime. As it says there: "The Desktop Runtime enables you to run existing Windows desktop applications. This release includes the .NET Core Runtime, you do not need to install it separately."

The ASP .NET Core runtime is only required if you intend to host .NET Core components on a web server, it has no connection to PrimalScript or PowerShell Studio and is neither required nor evaluated.
Alexander Riedel
SAPIEN Technologies, Inc.

eW_AMCIM
Posts: 3
Joined: Wed Jan 15, 2020 5:53 am

Re: Primalscript 2020 and Powershell V7 problem with debugging

Post by eW_AMCIM »

Aaaaaaah, now I see why I got confused. I've been installing the Core runtime on a lot of servers lately because of a new application we're implementing (all ASP.NET). When reading the prerequisites for Primalscript I thought I recognized it, didn't read properly and grabbed the installer I had been using all the time.

Just installed the right version, removed and rebuilt the 7 cache and everything is working fine now.

Thanks for your help, Alexander!