Page 1 of 1

Self Contained PowerShell Scripts

Posted: Wed Jan 30, 2019 1:22 pm
by ALIENQuake

I would like to know if there are any plans/investigation for Windows Forms project types + Script Packager to:

1. Include all files from Powershell 5.1 (and probably some part of Net 4.5.2 files) into exe itself
2. Once PowerShell Core has moved over to .NET Core 3.0 with Forms, include all files from Powershell Core and Net Core 3 into exe itself

So we could have self Contained PowerShell Scripts, without "install Net and Powershell otherwise it crashes" requirements?

BTW: I don't care if the app will have 150Mb filesize or more, space is no longer an issue as of 2019

Re: Self Contained PowerShell Scripts

Posted: Thu Jan 31, 2019 5:50 am
by Alexander Riedel
That is a loaded question. But in general, no, there are no such plans.
I mean, to be sure we will support PowerShell Core and .NET Core 3 if and when it has Forms support.
But adding ALL PowerShell assemblies and the entire framework to a single exe? No, that is not feasible, even if you do not consider space.
Considering the amount of time it would take to JIT compile the framework and powershell prior to launching your script, it better come with a free drip coffee maker.
All jokes aside, runtimes, frameworks etc exist as a shared resource for a reason. You cannot run PowerShell without it being properly installed. There are not only size and speed consideration, there are also security implications. I mean, if you already go that far, why not deploy your app with its own OS on a bootable image? Then you would even eliminate Windows as a pre-requisite.

Usually you eliminate the hurdles of missing pre-requisites by installing an app and have the Windows Installer take care of also installing any required runtimes or other apps.

I am assuming you have some frustration with missing bits in your environment. Why don't you elaborate on the type of applications you create with some background on what difficulties you face? Maybe we can make a few suggestions how to handle that without booting a "PowerShell OS" from a flash drive :D

Re: Self Contained PowerShell Scripts

Posted: Sat Feb 02, 2019 7:35 am
by ALIENQuake
First, let me address you concerns:
- you can run Powershell Core without installation, that's what Portable is for
- I'm not talking about JIT compiling framework, I'm talking about simple inclusion of NET + Powershell dll files
- security is no concern for me, my app is very simple and not executing as admin, besides, it's not the IDE/toolset to worry

next, let me present to you a scenario which I want to avoid
- after 10 years of broken application because of the NET updates, Microsoft finally acknowledge this problem and offer self-contained deployment of NET Core app. This is indisputable and I want the same for my app: ensure no dependency from shared NET so I can be sure that my app will work correctly 5 years from now
- the "let's ship whole os" argument is several magnitudes bigger and such concept it's not used by applications. Self-contained concept is used widley.

finally, I can't use windows installer
- my app is Portable out of the box, it dose't use any OS features (Right-Click entry etc) which require "Installation/UnInstallation", single exe
- Windows 7 support is highly important and using PS2 Host is not an option, I need Powershell 5.1 features

so I need a way to ship PS 5.1 and NET 4.5.2 for Windows 7. It's exactly the same situation as for Electron-based app: Electron ships local copy of Chrome. With self-contained exe, I could stop worrying about it. For me, nothing is more important.

I know that the chances for changing company vision by one random post are zero to none. But please reach to you customers (survey?) Such feature with the combination of that you are mention here: viewtopic.php?f=23&t=13612 looks fantastic for me.

Re: Self Contained PowerShell Scripts

Posted: Sat Feb 02, 2019 9:56 am
by Alexander Riedel
Thanks for your detailed answer.
We are aware that with Core things go more the **nix way, which basically enables XCopy installs. We are monitoring this and see what can be done once the dust settles on this.
.NET and JIT, basically ALL .NET applications are ILASM code. Which needs to be JIT (Just in time) compiled before running. Windows Update usually Pre-compiles a new framework, a fix thereof etc when installing, which is why sometimes your computer fans howls like a jet engine and everything is sluggish for an hour or so without you doing so much.

I am aware of the problem you describe, rest assured. Windows developers have faced that all along with static linking versus dynamic linking, so none of this is new. :D
Security is a big concern for us, sorry. We need to make VERY sure we do not inadvertently create back doors. So yes, it is for us to worry about.

There is some technology available that *might* mitigate the issue, so I'll do some research.

In the meantime, you can post a feature request ( which will allow others to weigh in and vote on that.

Re: Self Contained PowerShell Scripts

Posted: Sat Feb 02, 2019 10:23 am
by ALIENQuake
Many thanks, I've made FR.