End support for PowerShell v3/v4 in VSCode-PowerShell v2.0.0
Currently, supporting PowerShell v3 and v4 creates several challenges for us:
-
To get PSReadLine into the extension, we need changes coming in PSReadLine 2.0, which does not support v3/v4.
-
We are forced to use the v3 AST to support v3, which means:
-
Incompatibility in the APIs between v3, v4 and v5 mean that there are bugs that are hard to fix (and even hard to reproduce, since most of us don't have access to a machine running PowerShell v3 or v4).
-
Of the two CI systems we currently use and the others we are looking to invest in, none supports PowerShell v3/v4 natively.
-
v3/v4 usage is relatively low, and decreasing. With Windows Server 2019 around the corner and Server 2012 mainstream EOL also coming up this year, even more users will be moving to a newer PowerShell version.
-
The code base is fragmented and hard to maintain because:
- We have to compile against .NET Framework 4.5.1 and .NET Standard 1.6, when we would ideally compile against only .NET Standard. (This also spurs us toward better cross platform support)
- We also have compile time PowerShell version targets.
- Both of which lead to crazy .csproj files like this one.
- The .NET Framework/Standard stuff means the backend codebase is riddled with
#ifdefs. - There are also
#ifdefs for v3/v4 support. - There's also version conditional logic in the build and run tooling, but that's easier to work with.
This issue contains most of the discussion that's already been had about dropping v3/v4.
My suggestion is:
- Include a deprecation warning for ~6 months, starting when v2.0.0 of the extension is released as stable.
- Actually drop support for v3 and v4 6 months after that date.
- Increment the major version number when we do it.
- Ensure that PSScriptAnalyzer can analyze PowerShell feature support by version so that people can still write scripts for v3 and v4 using the VSCode extension (but with the extension host running v5+).
~Some additional things:~
- ~An alternative to some of this is to refactor much of our code to abstract away the differences. However, that could be a costly effort and lead to significant regressions.~
- ~We've also been talking about incrementing the major version of the extension with the addition of PSReadLine support. It seems a little cruel to me to drop v3/v4 support just as we add PSReadLine, but it also makes sense that both changes are big enough to mean a major version increase.~
UPDATE
The addition of PSReadLine depends on a new version of PSReadLine that requires PowerShell v5.1 or later. This is by far our biggest motivating factor for ending support for PowerShell v3/v4.
@dragonwolf83 Stop beating a dead horse. ISE is deprecated and a different beast.
Also to be clear, for those that still use v3/v4 you would still have 2 options:
- any v1.x PowerShell Editor Services editor like VSCode's extension (will still receive certain bug fixes)
- ISE which will be in Windows already (maintenance mode)
Also as folks have mentioned, you can still write a script that works on v3 while using a PSES editor (vscode) and 5.1 or 6.
In fact, PSScriptAnalyzer will have rules, I believe, that say "hey you're not compatible with this version" to help that scenario.
@TheIncorrigible1 by your definition, so is PowerShell v3-4. Besides, you missed the point. I'm not advocating ISE forever. I'm saying that Microsoft has no obligation to backport a new way to do an Editor to older versions. It is a nice to have but if it hinders development, I vote for the path @tylerl0706 mentioned above.
Also as folks have mentioned, you can still write a script that works on v3 while using a PSES editor (vscode) and 5.1 or 6. In fact, PSScriptAnalyzer will have rules, I believe, that say "hey you're not compatible with this version" to help that scenario.
The UseCompatibleCmdlets rule already does this and the next release will contain more version files. Future versions will also analyse the types compatibility and miscellaneous other things.
To summarise: I am rather worried about the PSES dropping support rather than the VSCode extension. However, having said that, this would mean that it would be at least nice if both versions get installed when installing the extension and at runtime the extension decides which one to use, to avoid having to manually dig out the old one. Keep in mind that people deliberately keep test boxes not updated to test that their PowerShell modules also work on older versions of PowerShell and therefore will need to visit the box from time to time for debugging purposes. PSSA has a WMF4 image in the build matrix here to run tests against v4, which means that other people do not need any VM setup for a PR.
@SeeminglyScience @tylerl0706 @rjmholt I have one more constructive idea to solve the PSES problem with the API problem Why don't you just use the latest Parser of PSCore itself (in general or for old versions like 3 or 4) since PSES seems to be just a .Net solution? I did a proof of concept a few months ago, where I was parsing a script to an AST on a Linux box that did not even have PowerShell installed at all. This is possible because one of the NuGet packages of the powershell-core feed (I think it was either PowerShell.SDK or System.Automation.Management) actually contains the whole Parser code and not just the reference assemblies.
@bergmeister
I am rather worried about the PSES dropping support rather than the VSCode extension.
I get the impression that you are worried this change is being made without other PSES implementations taken into consideration. We may disagree on this change, but I'd like to reassure you that when it comes to PSES changes, my primary concern is how it could effect future implementations. VSCode is a great example of what an implementation can do but the power of PSES comes from it's extensibility first and foremost. It is with that in mind that I've been fighting for this change for some time.
However, having said that, this would mean that it would be at least nice if both versions get installed when installing the extension and at runtime the extension decides which one to use, to avoid having to manually dig out the old one.
I'm not sure there is enough usage to justify implementing this. Personally I think the same about forking/porting fixes but I think that's a reasonable enough compromise for those worried by the change.
Keep in mind that people deliberately keep test boxes not updated to test that their PowerShell modules also work on older versions of PowerShell and therefore will need to visit the box from time to time for debugging purposes.
I think the big disconnect here, for me, is why VSCode (or any other editor) needs to be installed on these machines? Wouldn't it be preferable to debug from a PSSession? Or with something preexisting (ISE)?
PSSA has a WMF4 image in the build matrix here to run tests against v4, which means that other people do not need any VM setup for a PR.
That's great for final checks before merge, but doesn't help as much with development.
Why don't you just use the latest Parser of PSCore itself ... This is possible because one of the NuGet packages of the powershell-core feed (I think it was either PowerShell.SDK or System.Automation.Management)
The SDK does contain all the code required for that, but in order to reference it you need to target netcoreapp2.0. Right now we build two sets of assemblies, one for CoreCLR and one for FullCLR. We can't reference the SDK in the FullCLR build which is where we would want to use a newer API, and we already reference it in the CoreCLR build. Adding to that, PSES is hosted in a PowerShell session so even if we had a later version of SMA we could reference in FullCLR we can't override the one already loaded in the AppDomain.
I think there are significant enough reasons to look into ripping out the code for SMAL.Parser and adding some custom logic at some point. But that doesn't solve this problem, a lot more than the parser has changed since 3.0. Off the top of my head the debugger API has changed significantly from 3.0 to 5.1.
@seeminglyscience
The SDK does contain all the code required for that, but in order to reference it you need to target netcoreapp2.0
This was true for version 6.0.1 but with 6.0.2 they did it properly using netstandard2.0, shouldn't this allow you then to use it in Windows PowerShell where it gets compiled for the fullclr? AppDomains should normally allow you to use a different version even when being hosted in Windows PowerShell.
We will probably never agree on PSES support but at least having some integrated legacy mode to keep basic functionality would be nice. I will ask management for details/clarification but I can imagine that if they get the choice between taking something that works on any version or taking something that only works on the latest version but receives great improvements, they are likely going to prefer the former option then. Our clients are unfortunately often in a big corporate environment that is not very flexible. Personally I am all for using the latest and greatest stuff from a client and development point of view whereever possible but this is a tricky subject since it is affecting clients and not just us.
This was true for version 6.0.1 but with 6.0.2 they did it properly using netstandard2.0, shouldn't this allow you then to use it in Windows PowerShell where it gets compiled for the fullclr?
Maybe I'm getting it from the wrong place. Is there a way to reference the SDK other than this myget feed?
Sorry, you are right about this one (I must have misremembered something from a different NuGet package). It would be interesting if there is a reason why it is netcore and not netstandard since the api set is not vastly different between the two (maybe it could be already netstandard and it was just published like that?)
Would it be too much of an impact on the footprint to publish it as self-contained (i.e. include the required runtime)? Then you would have only one compilation target and could use the newer APIs in older versions of PS. There is already a feature (currently experimental so no official support at the moment) in the netcore linker to merge all published DLLs and trim out unneeded or duplicated IL (similar to how Mono already does it to have much smaller Xamarin apps) to end up with only very small binaries that need to be deployed whilst still containing all required dependencies? This also leads to a significant performance increase and you would then also not depend on the local PowerShell installation, which would probably lead to fewer bugs and easier REPROs. I don't know too many details about PSES yet but maybe it needs to be split to drop support only for a subset of it?
Keep both versions for another few years. I would suggest until Windows 2012 is out of extended support. There are servers, including those with Microsoft application on it which can't receive the required .net frameworks or wmf bases.
Thanks :)
I completely support this in light of PSv5.1 Desktop being "Complete" as per Snover@Summit this year. The use cases to develop exclusively for <5.1 is difficult to justify in my opinion. 5.1 installs on win2008r2 for crying out loud and generally, your not running your developed code there anyhow, you are remoting in and doing a couple things and getting a result to be processed somewhere else.
I fully support this to improve vscode for 5.1.
@Juanito99 Sure, there are servers running old PS versions. That's not what this is about, though. This is about dropping support for developing on VS Code and other editors that utilise this framework on future versions, so that we can focus on implementing new features for the new versions, such as providing better support for verifying a script will actually function on an earlier version of PS than is running on the development machine.
The sole reason I could see for not wanting to drop support for developing in environments with earlier versions of PS is if you're trying to do dev work and writing most of your scripts on servers running old Windows versions.
I really wouldn't see the point of hamstringing better support for developing for those versions and future versions just to support a use case that doesn't even really make sense. If you absolutely have to fiddle with scripts in the environment itself using the machine you'll be testing on, you can still run an old version of the extensions or just run the ISE for that brief moment.
@vexx32 Thanks for explanation. It turns out that I misunderstood the intention. So if I will be not able to run VSCode incl. PS on legacy server it is absolutely acceptable for me. :+1:
To me it is just important that I still can write scripts for those old machines.
Please go ahead, then. You guys are really doing an amazing job! :smile:
Just to clarify, @Juanito99, you will still be able to use VSCode, it just won't receive anymore features.
@tylerl0706 Nice, appreciate the clarification :bowing_man:
I can't think of any scenarios in my environment, where anyone would need to run VSCode-PowerShell on machines with WMF older than 5.1, so I'm all for it, especially considering that dropping support for older WMFs can make PSReadLine support come out sooner.
On a side note, the idea about maintaining two PowerShell-VSCode extension versions looks interesting. What if instead of creating deprecation warnings, and so on, you just roll out a new extension (i.e. VSCode-PowerShell-new, I'm sure we can come up with a better title) that's not going to have a dependency on the older WMF versions? That way, there will be no need to wait on any deprecation dates and allow those that run newer WMF versions on their dev stations get new functionality much quicker.
@Glober777 I was thinking more on the side of...
Currently we have just
"PowerShell"
we will bring that forward to the v2 version of the PowerShell extension supporting 5.1+.
We'll add a
"PowerShell (Legacy)"
For the 1.x version which will still work with v3/v4
I wasn't sure about this before, but worth noting now:
PSReadLine support depends on using PowerShell v5 and above -- the mechanism we need to integrate with the integrated console is in a newer PSReadLine version that does not support below PowerShell v5.
It's not necessarily true that adding PSReadLine would mean dropping v3/v4 support, but it would make things quite complex if we didn't.
Just to add to Rob's comment, you can track the adding of PSReadline here:
https://github.com/PowerShell/vscode-powershell/issues/535
The vast majority on this page are all saying the same thing. IDE != Runtime and it is therefore legitimate to have different requirements. Give us the tools to help us develop our code.
This seems like something that should have and RFC? Pretty significant decision/change.
"RFC documents for community feedback on design changes and improvements to PowerShell"
https://github.com/PowerShell/PowerShell-RFC/issues ?
I hope we can move forward with this change.