Skip to content

Use PSRL release and filter out previous betas #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 13, 2018
18 changes: 0 additions & 18 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,6 @@ task RestorePsesModules -After Build {
Save-Module @splatParameters
}

# TODO: Replace this with adding a new module to Save when a new PSReadLine release comes out to the Gallery
if (-not (Test-Path $PSScriptRoot/module/PSReadLine))
{
Write-Host "`tInstalling module: PSReadLine"

# Download AppVeyor zip
$jobId = (Invoke-RestMethod https://ci.appveyor.com/api/projects/lzybkr/PSReadLine).build.jobs[0].jobId
Invoke-RestMethod https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/bin%2FRelease%2FPSReadLine.zip -OutFile $PSScriptRoot/module/PSRL.zip

# Position PSReadLine
Expand-Archive $PSScriptRoot/module/PSRL.zip $PSScriptRoot/module/PSRL
Move-Item $PSScriptRoot/module/PSRL/PSReadLine $PSScriptRoot/module

# Clean up
Remove-Item -Force -Recurse $PSScriptRoot/module/PSRL.zip
Remove-Item -Force -Recurse $PSScriptRoot/module/PSRL
}

Write-Host "`n"
}

Expand Down
7 changes: 6 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ environment:

install:
- ps: |
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -force -confirm:$false -verbose }
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force -Confirm:$false -Verbose }
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
Install-PackageProvider -Name NuGet -Force | Out-Null
Import-PackageProvider NuGet -Force | Out-Null
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force | Out-Null
Expand Down
5 changes: 5 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
"MinimumVersion":"1.0",
"MaximumVersion":"1.99",
"AllowPrerelease":false
},
"PSReadLine":{
"MinimumVersion":"2.0.0-beta3",
"MaximumVersion":"2.1",
"AllowPrerelease":true
}
}
9 changes: 8 additions & 1 deletion scripts/travis.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -Scope CurrentUser -force -confirm:$false -verbose }
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Scope CurrentUser -Force -Confirm:$false -Verbose }
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
Install-PackageProvider -Name NuGet -Force | Out-Null
Import-PackageProvider NuGet -Force | Out-Null
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null

# Install InvokeBuild
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force
Expand Down
10 changes: 7 additions & 3 deletions src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class PSReadLinePromptContext : IPromptContext {
[System.Diagnostics.DebuggerHidden()]
[System.Diagnostics.DebuggerStepThrough()]
param()
return [Microsoft.PowerShell.PSConsoleReadLine]::ReadLine(
return [Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]::ReadLine(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkeithhill, @SeeminglyScience turns out:

  • PSCore 6.0 bundles and loaded PSReadLine.dll in $PSHome, so we need to use the assembly-qualified name of the type and we have to provide the version for it to work
  • Windows PowerShell doesn't like assembly-qualified names without the Culture and PublicKeyToken, so I had to add that too...........

But it works and we can take it out when PSCore 6.0 support is ended

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the bright side it's still a whole lot better than having to manually replace the DLL!

$Host.Runspace,
$ExecutionContext,
$args[0])";
Expand All @@ -30,13 +30,17 @@ internal class PSReadLinePromptContext : IPromptContext {
[System.Diagnostics.DebuggerStepThrough()]
param()
end {
$module = Get-Module -ListAvailable PSReadLine | Where-Object Version -ge '2.0.0' | Sort-Object -Descending Version | Select-Object -First 1
$module = Get-Module -ListAvailable PSReadLine |
Where-Object Version -eq '2.0.0' |
Where-Object { $_.PrivateData.PSData.Prerelease -notin 'beta1','beta2' } |
Sort-Object -Descending Version |
Select-Object -First 1
if (-not $module) {
return
}

Import-Module -ModuleInfo $module
return 'Microsoft.PowerShell.PSConsoleReadLine' -as [type]
return [Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]
}";

private readonly PowerShellContext _powerShellContext;
Expand Down