8000 Windows PowerShell Support and InvokeBuild by TylerLeonhardt · Pull Request #62 · PowerShell/Polaris · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Windows PowerShell Support and InvokeBuild #62

Merged
merged 4 commits into from
Nov 3, 2017

Conversation

TylerLeonhardt
Copy link
Member
@TylerLeonhardt TylerLeonhardt commented Nov 2, 2017

If you're resourceful enough, you'll notice that Polaris actually already supports Windows PowerShell. That's how we have a working AppVeyor build that runs Pester tests.

That said, I'm saying now that Polaris supports Windows PowerShell.

Polaris targets .NET Standard 2.0 and .NET Framework 4.5.1. If your version of PowerShell can import a dll from one of these libraries, you should be good to go.

If we need to target an even older version of the .NET Framework, please open an issue and I will address it. FYI HttpListener support Windows XP SP2 and up.

InvokeBuild

In addition to support for Windows PowerShell, we've onboarded to InvokeBuild. I find it really easy to use and it helps when deciding what frameworks to build on what machines.

Breaking change

This PR also includes a breaking change. PowerShell Core 6 beta 9 includes a breaking change to Get-Content that removes the -Encoding byte flag and replaces it with -AsByteStream. Polaris uses Get-Content for static routes. Since PowerShell Core 6 is still in beta, I'm only going to support the latest version of PowerShell Core 6. That said, static routes will no longer work with PowerShell Core 6 beta 8 and lower. Please move to PowerShell Core 6

Addressed:
#57
#11

@TylerLeonhardt TylerLeonhardt changed the title Onboard to [InvokeBuild](https://github.com/nightroman/Invoke-Build) Windows PowerShell Support and InvokeBuild Nov 3, 2017
@TylerLeonhardt TylerLeonhardt merged commit b1bf14d into master Nov 3, 2017
@TylerLeonhardt TylerLeonhardt deleted the onboad-to-Invoke-Build branch November 3, 2017 16:47
@affieuk
Copy link
Contributor
affieuk commented Nov 7, 2017

This doesn't seem to work with PowerShell v4, I ran Invoke-Build on my Windows 10 machine and was able to add a route, I then copied the Polaris folder to a 2012 R2 box and ran the below, both of which failed.

PS C:\>  Import-Module C:\Polaris\Polaris.psm1
PS C:\> New-GetRoute -Path /hello -ScriptBlock { $response.Send('Hello') }
Method invocation failed because [PolarisCore.Polaris] does not contain a method named 'new'.
At C:\Polaris\Polaris.psm1:581 char:9
+         $global:Polaris = [PolarisCore.Polaris]::new($logger)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

You cannot call a method on a null-valued expression.
At C:\Polaris\Polaris.psm1:71 char:5
+     $global:Polaris.AddRoute($Path, $Method, $ScriptBlock.ToString())
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.18773
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2
PS C:\> [PolarisCore.Polaris]::new($null)
Method invocation failed because [PolarisCore.Polaris] does not contain a method named 'new'.
At line:1 char:1
+ [PolarisCore.Polaris]::new($null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

@TylerLeonhardt
Copy link
Member Author

Good catch. I only tested this on Windows PowerShell 5 so that's my bad.

@TylerLeonhardt
Copy link
Member Author

Looks like new() is a PowerShell 5 thing :)

We'll have to try replacing that with New-Object PolarisCore.Polaris and see if that does the trick

@TylerLeonhardt
Copy link
Member Author

I opened this #64

Thanks for the report!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0