Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"-NoProfile",
"-NoExit",
"-Command",
"Import-Module '${workspaceFolder}/PSReadLine/bin/Debug/netstandard2.0/PSReadLine.psd1'"
"Import-Module '${workspaceFolder}/PSReadLine/bin/Debug/net8.0/PSReadLine.psd1'"
],
"console": "integratedTerminal",
"justMyCode": false,
Expand Down
10 changes: 3 additions & 7 deletions MockPSConsole/MockPSConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
<OutputType>Exe</OutputType>
<RootNamespace>MockPSConsole</RootNamespace>
<AssemblyName>MockPSConsole</AssemblyName>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<FileAlignment>512</FileAlignment>
<ApplicationManifest>Program.manifest</ApplicationManifest>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.2.24" />
<ItemGroup>
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.4.0" />
Comment thread
jshigetomi marked this conversation as resolved.
Outdated
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 17 additions & 35 deletions PSReadLine.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,40 @@ param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = (property Configuration Release),

[ValidateSet("net472", "net6.0")]
[string]$TestFramework,

[switch]$CheckHelpContent
)

Import-Module "$PSScriptRoot/tools/helper.psm1"

# Final bits to release go here
$targetDir = "bin/$Configuration/PSReadLine"
# Dynamically read target framework from project file
$csprojPath = "$PSScriptRoot/PSReadLine/PSReadLine.csproj"
[xml]$csproj = Get-Content $csprojPath
$targetFramework = $csproj.Project.PropertyGroup.TargetFramework | Where-Object { $_ } | Select-Object -First 1

if (-not $TestFramework) {
$TestFramework = $IsWindows ? "net472" : "net6.0"
if (-not $targetFramework) {
throw "Could not determine TargetFramework from $csprojPath"
}

Write-Verbose "Target framework: $targetFramework"

# Final bits to release go here
$targetDir = "bin/$Configuration/PSReadLine"
$TestFramework = $targetFramework
Comment thread
jshigetomi marked this conversation as resolved.
Outdated

function ConvertTo-CRLF([string] $text) {
$text.Replace("`r`n","`n").Replace("`n","`r`n")
}

$polyFillerParams = @{
Inputs = { Get-ChildItem Polyfill/*.cs, Polyfill/Polyfill.csproj }
Outputs = "Polyfill/bin/$Configuration/netstandard2.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll"
}

$binaryModuleParams = @{
Inputs = { Get-ChildItem PSReadLine/*.cs, PSReadLine/PSReadLine.csproj, PSReadLine/PSReadLineResources.resx, Polyfill/*.cs, Polyfill/Polyfill.csproj }
Outputs = "PSReadLine/bin/$Configuration/netstandard2.0/Microsoft.PowerShell.PSReadLine.dll"
Inputs = { Get-ChildItem PSReadLine/*.cs, PSReadLine/PSReadLine.csproj, PSReadLine/PSReadLineResources.resx }
Outputs = "PSReadLine/bin/$Configuration/$targetFramework/Microsoft.PowerShell.PSReadLine.dll"
}

$xUnitTestParams = @{
Inputs = { Get-ChildItem test/*.cs, test/*.json, test/PSReadLine.Tests.csproj }
Outputs = "test/bin/$Configuration/$TestFramework/PSReadLine.Tests.dll"
}

<#
Synopsis: Build the Polyfiller assembly
#>
task BuildPolyfiller @polyFillerParams {
exec { dotnet publish -c $Configuration -f 'netstandard2.0' Polyfill }
exec { dotnet publish -c $Configuration -f 'net6.0' Polyfill }
}

<#
Synopsis: Build main binary module
#>
Expand All @@ -79,7 +71,7 @@ task BuildXUnitTests @xUnitTestParams {
Synopsis: Run the unit tests
#>
task RunTests BuildMainModule, BuildXUnitTests, {
Write-Verbose "Run tests targeting '$TestFramework' ..."
Write-Verbose "Run tests targeting $targetFramework ..."
Start-TestRun -Configuration $Configuration -Framework $TestFramework
}

Expand All @@ -97,7 +89,7 @@ task CheckHelpContent -If $CheckHelpContent {
<#
Synopsis: Copy all of the files that belong in the module to one place in the layout for installation
#>
task LayoutModule BuildPolyfiller, BuildMainModule, {
task LayoutModule BuildMainModule, {
if (-not (Test-Path $targetDir -PathType Container)) {
New-Item $targetDir -ItemType Directory -Force > $null
}
Expand All @@ -115,17 +107,7 @@ task LayoutModule BuildPolyfiller, BuildMainModule, {
Set-Content -Path (Join-Path $targetDir (Split-Path $file -Leaf)) -Value (ConvertTo-CRLF $content) -Force
}

if (-not (Test-Path "$targetDir/netstd")) {
New-Item "$targetDir/netstd" -ItemType Directory -Force > $null
}
if (-not (Test-Path "$targetDir/net6plus")) {
New-Item "$targetDir/net6plus" -ItemType Directory -Force > $null
Comment thread
daxian-dbw marked this conversation as resolved.
}

Copy-Item "Polyfill/bin/$Configuration/netstandard2.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/netstd" -Force
Copy-Item "Polyfill/bin/$Configuration/net6.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/net6plus" -Force

$binPath = "PSReadLine/bin/$Configuration/netstandard2.0/publish"
$binPath = "PSReadLine/bin/$Configuration/$targetFramework/publish"
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine.dll $targetDir
Copy-Item $binPath/Microsoft.PowerShell.Pager.dll $targetDir

Expand Down
17 changes: 8 additions & 9 deletions PSReadLine/PSReadLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
<RootNamespace>Microsoft.PowerShell.PSReadLine</RootNamespace>
<AssemblyName>Microsoft.PowerShell.PSReadLine</AssemblyName>
<NoWarn>$(NoWarn);CA1416</NoWarn>
<AssemblyVersion>2.4.5.0</AssemblyVersion>
<FileVersion>2.4.5</FileVersion>
<InformationalVersion>2.4.5</InformationalVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<InformationalVersion>3.0.0</InformationalVersion>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
<PackageReference Include="Microsoft.CSharp" version="4.7.0" />
<PackageReference Include="Microsoft.PowerShell.Pager" version="1.0.0" />
<ProjectReference Include="..\Polyfill\Polyfill.csproj" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.0" />
Comment thread
jshigetomi marked this conversation as resolved.
Outdated
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Comment thread
daxian-dbw marked this conversation as resolved.
Outdated
<PackageReference Include="Microsoft.PowerShell.Pager" Version="1.0.0" />
</ItemGroup>

Comment thread
daxian-dbw marked this conversation as resolved.
Outdated
<ItemGroup>
<None Include="PSReadLine.psd1" CopyToOutputDirectory="PreserveNewest" />
<None Include="PSReadLine.psm1" CopyToOutputDirectory="PreserveNewest" />
Expand Down
4 changes: 2 additions & 2 deletions PSReadLine/PSReadLine.psd1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@{
RootModule = 'PSReadLine.psm1'
NestedModules = @("Microsoft.PowerShell.PSReadLine.dll")
ModuleVersion = '2.4.5'
ModuleVersion = '3.0.0'
GUID = '5714753b-2afd-4492-a5fd-01d9e2cff8b5'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = '(c) Microsoft Corporation. All rights reserved.'
Description = 'Great command line editing in the PowerShell console host'
PowerShellVersion = '5.1'
PowerShellVersion = '7.4'
FormatsToProcess = 'PSReadLine.format.ps1xml'
AliasesToExport = @()
FunctionsToExport = 'PSConsoleHostReadLine'
Expand Down
14 changes: 14 additions & 0 deletions PSReadLine/PSReadLine.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Check PowerShell version compatibility
if ($PSVersionTable.PSVersion -lt [Version]'7.4.0') {
$errorMessage = @"
PSReadLine 3.0+ requires PowerShell 7.4 or later.
Current version: $($PSVersionTable.PSVersion)

To use PSReadLine with your PowerShell version, install an older version:
Install-Module PSReadLine -RequiredVersion 2.4.5 -Force -SkipPublisherCheck

To upgrade PowerShell: https://aka.ms/install-powershell
"@
throw $errorMessage
}
Comment thread
daxian-dbw marked this conversation as resolved.
Outdated

function PSConsoleHostReadLine
{
[System.Diagnostics.DebuggerHidden()]
Expand Down
Loading