1919 [ValidateSet (" Debug" , " Release" )]
2020 [string ]$Configuration = (property Configuration Release),
2121
22- [ValidateSet (" net462 " , " net6.0" )]
23- [string ]$Framework ,
22+ [ValidateSet (" net472 " , " net6.0" )]
23+ [string ]$TestFramework ,
2424
2525 [switch ]$CheckHelpContent
2626)
@@ -30,71 +30,58 @@ Import-Module "$PSScriptRoot/tools/helper.psm1"
3030# Final bits to release go here
3131$targetDir = " bin/$Configuration /PSReadLine"
3232
33- if (-not $Framework )
34- {
35- $Framework = if ($PSVersionTable.PSEdition -eq " Core" ) { " net6.0" } else { " net462" }
33+ if (-not $TestFramework ) {
34+ $TestFramework = $IsWindows ? " net472" : " net6.0"
3635}
3736
38- Write-Verbose " Building for '$Framework '" - Verbose
39-
4037function ConvertTo-CRLF ([string ] $text ) {
4138 $text.Replace (" `r`n " , " `n " ).Replace(" `n " , " `r`n " )
4239}
4340
4441$polyFillerParams = @ {
4542 Inputs = { Get-ChildItem Polyfill/* .cs, Polyfill/ Polyfill.csproj }
46- Outputs = " Polyfill/bin/$Configuration /$Framework /Microsoft.PowerShell.PSReadLine.Polyfiller.dll"
43+ Outputs = " Polyfill/bin/$Configuration /netstandard2.0 /Microsoft.PowerShell.PSReadLine.Polyfiller.dll"
4744}
4845
4946$binaryModuleParams = @ {
5047 Inputs = { Get-ChildItem PSReadLine/* .cs, PSReadLine/ PSReadLine.csproj, PSReadLine/ PSReadLineResources.resx, Polyfill/* .cs, Polyfill/ Polyfill.csproj }
51- Outputs = " PSReadLine/bin/$Configuration /$Framework /Microsoft.PowerShell.PSReadLine2 .dll"
48+ Outputs = " PSReadLine/bin/$Configuration /netstandard2.0 /Microsoft.PowerShell.PSReadLine .dll"
5249}
5350
5451$xUnitTestParams = @ {
5552 Inputs = { Get-ChildItem test/* .cs, test/* .json, test/ PSReadLine.Tests.csproj }
56- Outputs = " test/bin/$Configuration /$Framework /PSReadLine.Tests.dll"
57- }
58-
59- $mockPSConsoleParams = @ {
60- Inputs = { Get-ChildItem MockPSConsole/* .cs, MockPSConsole/ Program.manifest, MockPSConsole/ MockPSConsole.csproj }
61- Outputs = " MockPSConsole/bin/$Configuration /$Framework /MockPSConsole.dll"
53+ Outputs = " test/bin/$Configuration /$TestFramework /PSReadLine.Tests.dll"
6254}
6355
6456<#
6557Synopsis: Build the Polyfiller assembly
6658#>
67- task BuildPolyfiller @polyFillerParams - If ($Framework -eq " net462" ) {
68- # # Build both "net462" and "net6.0"
69- exec { dotnet publish -f " net462" - c $Configuration Polyfill }
70- exec { dotnet publish -f " net6.0" - c $Configuration Polyfill }
59+ task BuildPolyfiller @polyFillerParams {
60+ exec { dotnet publish - c $Configuration -f ' netstandard2.0' Polyfill }
61+ exec { dotnet publish - c $Configuration -f ' net6.0' Polyfill }
7162}
7263
7364<#
7465Synopsis: Build main binary module
7566#>
7667task BuildMainModule @binaryModuleParams {
77- exec { dotnet publish -f $Framework - c $Configuration PSReadLine }
68+ exec { dotnet publish - c $Configuration PSReadLine\PSReadLine.csproj }
7869}
7970
8071<#
8172Synopsis: Build xUnit tests
8273#>
8374task BuildXUnitTests @xUnitTestParams {
84- exec { dotnet publish -f $Framework - c $Configuration test }
85- }
86-
87- <#
88- Synopsis: Build the mock powershell console.
89- #>
90- task BuildMockPSConsole @mockPSConsoleParams {
91- exec { dotnet publish -f $Framework - c $Configuration MockPSConsole }
75+ exec { dotnet publish -f $TestFramework - c $Configuration test }
9276}
9377
9478<#
9579Synopsis: Run the unit tests
9680#>
97- task RunTests BuildMainModule, BuildXUnitTests, { Start-TestRun - Configuration $Configuration - Framework $Framework }
81+ task RunTests BuildMainModule, BuildXUnitTests, {
82+ Write-Verbose " Run tests targeting '$TestFramework ' ..."
83+ Start-TestRun - Configuration $Configuration - Framework $TestFramework
84+ }
9885
9986<#
10087Synopsis: Check if the help content is in sync.
@@ -128,35 +115,27 @@ task LayoutModule BuildPolyfiller, BuildMainModule, {
128115 Set-Content - Path (Join-Path $targetDir (Split-Path $file - Leaf)) - Value (ConvertTo-CRLF $content ) - Force
129116 }
130117
131- if ($Framework -eq " net462" ) {
132- if (-not (Test-Path " $targetDir /net462" )) {
133- New-Item " $targetDir /net462" - ItemType Directory - Force > $null
134- }
135- if (-not (Test-Path " $targetDir /net6plus" )) {
136- New-Item " $targetDir /net6plus" - ItemType Directory - Force > $null
137- }
138-
139- Copy-Item " Polyfill/bin/$Configuration /net462/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" " $targetDir /net462" - Force
140- Copy-Item " Polyfill/bin/$Configuration /net6.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" " $targetDir /net6plus" - Force
118+ if (-not (Test-Path " $targetDir /netstd" )) {
119+ New-Item " $targetDir /netstd" - ItemType Directory - Force > $null
120+ }
121+ if (-not (Test-Path " $targetDir /net6plus" )) {
122+ New-Item " $targetDir /net6plus" - ItemType Directory - Force > $null
141123 }
142124
143- $binPath = " PSReadLine/bin/$Configuration /$Framework /publish"
144- Copy-Item $binPath / Microsoft.PowerShell.PSReadLine2.dll $targetDir
125+ Copy-Item " Polyfill/bin/$Configuration /netstandard2.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" " $targetDir /netstd" - Force
126+ Copy-Item " Polyfill/bin/$Configuration /net6.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" " $targetDir /net6plus" - Force
127+
128+ $binPath = " PSReadLine/bin/$Configuration /netstandard2.0/publish"
129+ Copy-Item $binPath / Microsoft.PowerShell.PSReadLine.dll $targetDir
145130 Copy-Item $binPath / Microsoft.PowerShell.Pager.dll $targetDir
146131
147132 if ($Configuration -eq ' Debug' ) {
148133 Copy-Item $binPath /* .pdb $targetDir
149134 }
150135
151- if (Test-Path $binPath / System.Runtime.InteropServices.RuntimeInformation.dll) {
152- Copy-Item $binPath / System.Runtime.InteropServices.RuntimeInformation.dll $targetDir
153- } else {
154- Write-Warning " Build using $Framework is not sufficient to be downlevel compatible"
155- }
156-
157136 # Copy module manifest, but fix the version to match what we've specified in the binary module.
158137 $moduleManifestContent = ConvertTo-CRLF (Get-Content - Path ' PSReadLine/PSReadLine.psd1' - Raw)
159- $versionInfo = (Get-ChildItem - Path $targetDir / Microsoft.PowerShell.PSReadLine2 .dll).VersionInfo
138+ $versionInfo = (Get-ChildItem - Path $targetDir / Microsoft.PowerShell.PSReadLine .dll).VersionInfo
160139 $version = $versionInfo.FileVersion
161140 $semVer = $versionInfo.ProductVersion
162141
0 commit comments