diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 4cbfc6f17..bb3ee01ad 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -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" } diff --git a/appveyor.yml b/appveyor.yml index 24b302c32..c863ca18b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/modules.json b/modules.json index e4555e5de..621655464 100644 --- a/modules.json +++ b/modules.json @@ -8,5 +8,10 @@ "MinimumVersion":"1.0", "MaximumVersion":"1.99", "AllowPrerelease":false + }, + "PSReadLine":{ + "MinimumVersion":"2.0.0-beta3", + "MaximumVersion":"2.1", + "AllowPrerelease":true } } diff --git a/scripts/travis.ps1 b/scripts/travis.ps1 index 5af67b0dd..51dd4859f 100644 --- a/scripts/travis.ps1 +++ b/scripts/travis.ps1 @@ -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 diff --git a/src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs b/src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs index 53aa59121..c0707d026 100644 --- a/src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs +++ b/src/PowerShellEditorServices/Session/PSReadLinePromptContext.cs @@ -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( $Host.Runspace, $ExecutionContext, $args[0])"; @@ -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;