Migrate PSReadLine to target .NET 8.0 (#5055)

This commit is contained in:
Justin Chung
2026-01-20 11:05:10 -08:00
committed by GitHub
parent 6fa5711700
commit e563a2fc15
15 changed files with 62 additions and 378 deletions
+1 -1
View File
@@ -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,
+3 -7
View File
@@ -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.13" />
</ItemGroup>
<ItemGroup>
+19 -38
View File
@@ -19,46 +19,37 @@ param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = (property Configuration Release),
[ValidateSet("net472", "net6.0")]
[string]$TestFramework,
[switch]$CheckHelpContent
)
Import-Module "$PSScriptRoot/tools/helper.psm1"
# 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 $targetFramework) {
throw "Could not determine TargetFramework from $csprojPath"
}
Write-Verbose "Target framework: $targetFramework"
# Final bits to release go here
$targetDir = "bin/$Configuration/PSReadLine"
if (-not $TestFramework) {
$TestFramework = $IsWindows ? "net472" : "net6.0"
}
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 }
Outputs = "test/bin/$Configuration/$targetFramework/PSReadLine.Tests.dll"
}
<#
@@ -72,15 +63,15 @@ task BuildMainModule @binaryModuleParams {
Synopsis: Build xUnit tests
#>
task BuildXUnitTests @xUnitTestParams {
exec { dotnet publish -f $TestFramework -c $Configuration test }
exec { dotnet publish -f $targetFramework -c $Configuration test }
}
<#
Synopsis: Run the unit tests
#>
task RunTests BuildMainModule, BuildXUnitTests, {
Write-Verbose "Run tests targeting '$TestFramework' ..."
Start-TestRun -Configuration $Configuration -Framework $TestFramework
Write-Verbose "Run tests targeting $targetFramework ..."
Start-TestRun -Configuration $Configuration -Framework $targetFramework
}
<#
@@ -97,7 +88,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
}
@@ -115,17 +106,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
}
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
+1 -1
View File
@@ -178,7 +178,7 @@ namespace Microsoft.PowerShell
// Our tests expect that the default inline-view color is set to the new color, so we configure
// the color based on system environment only if we are not in test runs.
if (AppDomain.CurrentDomain.FriendlyName is not "PSReadLine.Tests")
if (AppDomain.CurrentDomain.FriendlyName is not "testhost")
{
DefaultInlinePredictionColor =
Environment.OSVersion.Version.Build >= 22621 // on Windows 11 22H2 or newer versions
-37
View File
@@ -1,37 +0,0 @@
using System;
using System.IO;
using System.Management.Automation;
using System.Reflection;
namespace Microsoft.PowerShell.PSReadLine
{
public class OnModuleImportAndRemove : IModuleAssemblyInitializer, IModuleAssemblyCleanup
{
public void OnImport()
{
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
}
public void OnRemove(PSModuleInfo module)
{
AppDomain.CurrentDomain.AssemblyResolve -= ResolveAssembly;
}
/// <summary>
/// Load the correct 'Polyfiller' assembly based on the runtime.
/// </summary>
private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
if (args.Name != "Microsoft.PowerShell.PSReadLine.Polyfiller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
{
return null;
}
string root = Path.GetDirectoryName(typeof(OnModuleImportAndRemove).Assembly.Location);
string subd = (Environment.Version.Major >= 6) ? "net6plus" : "netstd";
string path = Path.Combine(root, subd, "Microsoft.PowerShell.PSReadLine.Polyfiller.dll");
return Assembly.LoadFrom(path);
}
}
}
+9 -8
View File
@@ -5,21 +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="System.Management.Automation" Version="7.4.13">
<ExcludeAssets>contentFiles</ExcludeAssets>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.PowerShell.Pager" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
+2 -2
View File
@@ -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'
-232
View File
@@ -1,232 +0,0 @@
#if LEGACY
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Management.Automation.Language;
namespace System.Management.Automation.Subsystem.Prediction
{
/// <summary>
/// Kinds of prediction clients.
/// </summary>
public enum PredictionClientKind
{
/// <summary>
/// A terminal client, representing the command-line experience.
/// </summary>
Terminal,
/// <summary>
/// An editor client, representing the editor experience.
/// </summary>
Editor,
}
/// <summary>
/// The class represents a client that interacts with predictors.
/// </summary>
public sealed class PredictionClient
{
/// <summary>
/// Gets the client name.
/// </summary>
[HiddenAttribute]
public string Name { get; }
/// <summary>
/// Gets the client kind.
/// </summary>
[HiddenAttribute]
public PredictionClientKind Kind { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PredictionClient"/> class.
/// </summary>
/// <param name="name">Name of the interactive client.</param>
/// <param name="kind">Kind of the interactive client.</param>
[HiddenAttribute]
public PredictionClient(string name, PredictionClientKind kind)
{
Name = name;
Kind = kind;
}
}
/// <summary>
/// The class represents the prediction result from a predictor.
/// </summary>
public sealed class PredictionResult
{
/// <summary>
/// Gets the Id of the predictor.
/// </summary>
[HiddenAttribute]
public Guid Id { get; }
/// <summary>
/// Gets the name of the predictor.
/// </summary>
[HiddenAttribute]
public string Name { get; }
/// <summary>
/// Gets the mini-session id that represents a specific invocation that returns this result.
/// When it's not specified, it's considered by a client that the predictor doesn't expect feedback.
/// </summary>
[HiddenAttribute]
public uint? Session { get; }
/// <summary>
/// Gets the suggestions.
/// </summary>
[HiddenAttribute]
public IReadOnlyList<PredictiveSuggestion> Suggestions { get; }
internal PredictionResult(Guid id, string name, uint? session, List<PredictiveSuggestion> suggestions)
{
Id = id;
Name = name;
Session = session;
Suggestions = suggestions;
}
}
/// <summary>
/// The class represents a predictive suggestion generated by a predictor.
/// </summary>
public sealed class PredictiveSuggestion
{
/// <summary>
/// Gets the suggestion.
/// </summary>
[HiddenAttribute]
public string SuggestionText { get; }
/// <summary>
/// Gets the tooltip of the suggestion.
/// </summary>
[HiddenAttribute]
public string ToolTip { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PredictiveSuggestion"/> class.
/// </summary>
/// <param name="suggestion">The predictive suggestion text.</param>
[HiddenAttribute]
public PredictiveSuggestion(string suggestion)
: this(suggestion, toolTip: null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PredictiveSuggestion"/> class.
/// </summary>
/// <param name="suggestion">The predictive suggestion text.</param>
/// <param name="toolTip">The tooltip of the suggestion.</param>
[HiddenAttribute]
public PredictiveSuggestion(string suggestion, string toolTip)
{
if (string.IsNullOrEmpty(suggestion))
{
throw new ArgumentNullException(nameof(suggestion));
}
SuggestionText = suggestion;
ToolTip = toolTip;
}
}
/// <summary>
/// Provides a set of possible predictions for given input.
/// </summary>
public static class CommandPrediction
{
/// <summary>
/// Collect the predictive suggestions from registered predictors using the default timeout.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="ast">The <see cref="Ast"/> object from parsing the current command line input.</param>
/// <param name="astTokens">The <see cref="Token"/> objects from parsing the current command line input.</param>
/// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
[HiddenAttribute]
public static Task<List<PredictionResult>> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens)
{
return null;
}
/// <summary>
/// Collect the predictive suggestions from registered predictors using the specified timeout.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="ast">The <see cref="Ast"/> object from parsing the current command line input.</param>
/// <param name="astTokens">The <see cref="Token"/> objects from parsing the current command line input.</param>
/// <param name="millisecondsTimeout">The milliseconds to timeout.</param>
/// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
[HiddenAttribute]
public static Task<List<PredictionResult>> PredictInputAsync(PredictionClient client, Ast ast, Token[] astTokens, int millisecondsTimeout)
{
return null;
}
/// <summary>
/// Allow registered predictors to do early processing when a command line is accepted.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="history">History command lines provided as references for prediction.</param>
[HiddenAttribute]
public static void OnCommandLineAccepted(PredictionClient client, IReadOnlyList<string> history)
{
}
/// <summary>
/// Allow registered predictors to know the execution result (success/failure) of the last accepted command line.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="commandLine">The last accepted command line.</param>
/// <param name="success">Whether the execution of the last command line was successful.</param>
[HiddenAttribute]
public static void OnCommandLineExecuted(PredictionClient client, string commandLine, bool success)
{
}
/// <summary>
/// Send feedback to a predictor when one or more suggestions from it were displayed to the user.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="predictorId">The identifier of the predictor whose prediction result was accepted.</param>
/// <param name="session">The mini-session where the displayed suggestions came from.</param>
/// <param name="countOrIndex">
/// When the value is <code>> 0</code>, it's the number of displayed suggestions from the list returned in <see cref="session"/>, starting from the index 0.
/// When the value is <code><= 0</code>, it means a single suggestion from the list got displayed, and the index is the absolute value.
/// </param>
[HiddenAttribute]
public static void OnSuggestionDisplayed(PredictionClient client, Guid predictorId, uint session, int countOrIndex)
{
}
/// <summary>
/// Send feedback to predictors about their last suggestions.
/// </summary>
/// <param name="client">Represents the client that initiates the call.</param>
/// <param name="predictorId">The identifier of the predictor whose prediction result was accepted.</param>
/// <param name="session">The mini-session where the accepted suggestion came from.</param>
/// <param name="suggestionText">The accepted suggestion text.</param>
[HiddenAttribute]
public static void OnSuggestionAccepted(PredictionClient client, Guid predictorId, uint session, string suggestionText)
{
}
}
}
#else
using System.Management.Automation.Subsystem.Prediction;
using System.Runtime.CompilerServices;
[assembly: TypeForwardedTo(typeof(PredictionClientKind))]
[assembly: TypeForwardedTo(typeof(PredictionClient))]
[assembly: TypeForwardedTo(typeof(PredictiveSuggestion))]
[assembly: TypeForwardedTo(typeof(PredictionResult))]
[assembly: TypeForwardedTo(typeof(CommandPrediction))]
#endif
-22
View File
@@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.PowerShell.PSReadLine.Polyfiller</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Management.Automation" Version="7.2.24" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);LEGACY</DefineConstants>
</PropertyGroup>
</Project>
+1 -1
View File
@@ -19,7 +19,7 @@ build_script:
./build.ps1 -Configuration Release
test_script:
- pwsh: ./build.ps1 -Test -Configuration Release -Framework net472
- pwsh: ./build.ps1 -Test -Configuration Release
artifacts:
- path: .\bin\Release\PSReadLine.zip
+5 -15
View File
@@ -5,18 +5,20 @@
A script that provides simple entry points for bootstrapping, building and testing.
.DESCRIPTION
A script to make it easy to bootstrap, build and run tests.
This build targets .NET 8.0, which is the runtime for PowerShell 7.4 LTS.
PowerShell 7.4 LTS is supported until November 2026.
.EXAMPLE
PS > .\build.ps1 -Bootstrap
Check and install prerequisites for the build.
.EXAMPLE
PS > .\build.ps1 -Configuration Release
Build the main module with 'Release' configuration targeting 'netstandard2.0'.
Build the project in Release configuration.
.EXAMPLE
PS > .\build.ps1
Build the main module with the default configuration (Debug) targeting 'netstandard2.0'.
Build the main module with the default configuration (Debug) configuration.
.EXAMPLE
PS > .\build.ps1 -Test
Run xUnit tests with the default configuration (Debug) and the default target framework (net472 on Windows or net6.0 otherwise).
Run xUnit tests with the default configuration.
.PARAMETER Clean
Clean the local repo, but keep untracked files.
.PARAMETER Bootstrap
@@ -25,13 +27,6 @@
Run tests.
.PARAMETER Configuration
The configuration setting for the build. The default value is 'Debug'.
.PARAMETER Framework
The target framework when testing:
- net472: run tests with .NET Framework
- net6.0: run tests with .NET 6.0
When not specified, the target framework is determined by the current OS platform:
- use 'net472' on Windows
- use 'net6.0' on Unix platforms
#>
[CmdletBinding(DefaultParameterSetName = 'default')]
param(
@@ -47,10 +42,6 @@ param(
[Parameter(ParameterSetName = 'test')]
[switch] $CheckHelpContent,
[Parameter(ParameterSetName = 'test')]
[ValidateSet("net472", "net6.0")]
[string] $Framework,
[Parameter(ParameterSetName = 'default')]
[Parameter(ParameterSetName = 'test')]
[ValidateSet("Debug", "Release")]
@@ -93,7 +84,6 @@ if (-not (Get-Module -Name InvokeBuild -ListAvailable)) {
$buildTask = if ($Test) { "RunTests" } else { "ZipRelease" }
$arguments = @{ Task = $buildTask; Configuration = $Configuration }
if ($Framework) { $arguments.Add("TestFramework", $Framework) }
if ($CheckHelpContent) { $arguments.Add("CheckHelpContent", $true) }
Invoke-Build @arguments
+5
View File
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "8.0.415"
}
}
+1 -1
View File
@@ -638,7 +638,7 @@ namespace Test
Assert.Equal(Guid.Empty, _mockedMethods.acceptedPredictorId);
Assert.Null(_mockedMethods.acceptedSuggestion);
Assert.NotNull(_mockedMethods.commandHistory);
Assert.Equal(1, _mockedMethods.commandHistory.Count);
Assert.Single(_mockedMethods.commandHistory);
Assert.Equal("netsh show me", _mockedMethods.commandHistory[0]);
_mockedMethods.ClearPredictionFields();
+3 -8
View File
@@ -5,7 +5,7 @@
<OutputType>library</OutputType>
<RootNamespace>UnitTestPSReadLine</RootNamespace>
<AssemblyName>PSReadLine.Tests</AssemblyName>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<IsCodedUITest>False</IsCodedUITest>
@@ -14,13 +14,8 @@
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<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.13" />
</ItemGroup>
<ItemGroup>
+12 -5
View File
@@ -1,9 +1,13 @@
$MinimalSDKVersion = '6.0.425'
$IsWindowsEnv = [System.Environment]::OSVersion.Platform -eq "Win32NT"
$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path
$LocalDotnetDirPath = if ($IsWindowsEnv) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" }
# Read the required SDK version from global.json
$globalJsonPath = Join-Path $RepoRoot "global.json"
$globalJson = Get-Content -Path $globalJsonPath -Raw | ConvertFrom-Json
$MinimalSDKVersion = $globalJson.sdk.version
<#
.SYNOPSIS
Get the path of the currently running powershell executable.
@@ -54,7 +58,7 @@ function Test-DotnetSDK
if (Test-Path $dotnetExePath) {
$installedVersion = & $dotnetExePath --version
return $installedVersion -ge $MinimalSDKVersion
return [Version]::new($installedVersion) -ge [Version]::new($MinimalSDKVersion)
}
return $false
}
@@ -211,13 +215,15 @@ function Start-TestRun
function RunXunitTestsInNewProcess ([string] $Layout, [string] $OperatingSystem)
{
$filter = if ($Layout) {
Write-Log "Testing $Layout on $OperatingSystem...`n"
Write-Log "`nTesting $Layout on $OperatingSystem..."
"FullyQualifiedName~Test.{0}_{1}" -f ($Layout -replace '-','_'), $OperatingSystem
} else {
## Today, tests for screen-reader mode only run on Windows with the 'en-US' layout.
Write-Log "Testing screen reader mode...`n"
$Layout = "screen-reader"
Write-Log "`nTesting $Layout mode..."
"FullyQualifiedName~Test.ScreenReader"
}
$testResultFile = "xUnitTestResults.{0}.xml" -f $Layout
$testResultFile = Join-Path $testResultFolder $testResultFile
@@ -279,7 +285,7 @@ function Start-TestRun
}
else
{
Write-Log "Testing not supported for the keyboard layout '$layout'."
Write-Log "`nTesting not supported for the keyboard layout '$layout'."
}
}
}
@@ -289,6 +295,7 @@ function Start-TestRun
$null = [KeyboardLayoutHelper]::SetKeyboardLayout($savedLayout)
}
}
RunXunitTestsInNewProcess
}
else