Skip to content

Add PowerShell 7.4 SDK and net8.0 framework #2114

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 9 commits into from
Dec 15, 2023
Merged
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ dotnet_diagnostic.IDE0026.severity = error
# IDE0027: Use expression body for accessors
dotnet_diagnostic.IDE0027.severity = error
# IDE0028: Use collection initializers
dotnet_diagnostic.IDE0028.severity = error
dotnet_diagnostic.IDE0028.severity = suggestion
# IDE0029: Use coalesce expression (non-nullable types)
dotnet_diagnostic.IDE0029.severity = error
# IDE0030: Use coalesce expression (nullable types)
Expand Down Expand Up @@ -219,7 +219,7 @@ dotnet_diagnostic.IDE0082.severity = error
# IDE0083: Use pattern matching (not operator)
dotnet_diagnostic.IDE0083.severity = error
# IDE0090: Simplify new expression
dotnet_diagnostic.IDE0090.severity = error
dotnet_diagnostic.IDE0090.severity = suggestion
# IDE0100: Remove unnecessary equality operator
dotnet_diagnostic.IDE0100.severity = error
# IDE0110: Remove unnecessary discard
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ jobs:
dotnet-version: |
6.0.x
7.0.x
8.0.x

- name: Install PSResources
shell: pwsh
run: tools/installPSResources.ps1

- name: Build and test
shell: pwsh
run: Invoke-Build
run: Invoke-Build ${{ github.event_name == 'merge_group' && 'TestFull' || 'Test' }}

- name: Upload build artifacts
if: always()
Expand Down
6 changes: 3 additions & 3 deletions .vsts-ci/azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
steps:
- template: templates/ci-general.yml

- job: macOS11
displayName: macOS 11
- job: macOS12
displayName: macOS 12
pool:
vmImage: macOS-11
vmImage: macOS-12
steps:
- template: templates/ci-general.yml

Expand Down
4 changes: 0 additions & 4 deletions .vsts-ci/misc-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: Misc-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr)

trigger:
- gh-readonly-queue/main/*
pr:
paths:
exclude:
- '**/*.md'

resources:
repositories:
Expand Down
27 changes: 12 additions & 15 deletions .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,35 @@ steps:
script: $PSVersionTable

- task: UseDotNet@2
displayName: Install .NET 7.0.x SDK
displayName: Install .NET 8.x SDK
inputs:
packageType: sdk
version: 7.0.x
performMultiLevelLookup: true
version: 8.x

- task: UseDotNet@2
displayName: Install .NET 6.0.x runtime
displayName: Install .NET 7.x runtime
inputs:
packageType: runtime
version: 6.0.x
performMultiLevelLookup: true
version: 7.x

- task: PowerShell@2
displayName: Install PSResources
- task: UseDotNet@2
displayName: Install .NET 6.x runtime
inputs:
pwsh: true
filePath: tools/installPSResources.ps1
packageType: runtime
version: 6.x

- task: PowerShell@2
displayName: Build
displayName: Install PSResources
inputs:
targetType: inline
pwsh: true
script: Invoke-Build Build -Configuration Release
filePath: tools/installPSResources.ps1

- task: PowerShell@2
displayName: Test
displayName: Build and test
inputs:
targetType: inline
pwsh: true
script: Invoke-Build Test -Configuration Release
script: Invoke-Build TestFull -Configuration Release

- task: PublishTestResults@2
displayName: Publish test results
Expand Down
115 changes: 80 additions & 35 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ $script:IsArm64 = -not $script:IsNix -and @("ARM64") -contains $env:PROCESSOR_AR
$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs")
$script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props")

$script:NetRuntime = @{
$script:NetFramework = @{
PS51 = 'net462'
PS72 = 'net6.0'
PS73 = 'net7.0'
Desktop = 'net462'
PS74 = 'net8.0'
Standard = 'netstandard2.0'
}

$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS72)/publish"
$script:HostDeskOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.Desktop)/publish"
$script:PsesOutput = "$PSScriptRoot/src/PowerShellEditorServices/bin/$Configuration/$($script:NetRuntime.Standard)/publish"
$script:VSCodeOutput = "$PSScriptRoot/src/PowerShellEditorServices.VSCode/bin/$Configuration/$($script:NetRuntime.Standard)/publish"
$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS72)/publish"
$script:HostDeskOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS51)/publish"
$script:PsesOutput = "$PSScriptRoot/src/PowerShellEditorServices/bin/$Configuration/$($script:NetFramework.Standard)/publish"
$script:VSCodeOutput = "$PSScriptRoot/src/PowerShellEditorServices.VSCode/bin/$Configuration/$($script:NetFramework.Standard)/publish"

if (Get-Command git -ErrorAction SilentlyContinue) {
# ignore changes to this file
Expand All @@ -69,8 +70,8 @@ Task FindDotNet {
Assert (Get-Command dotnet -ErrorAction SilentlyContinue) "dotnet not found, please install it: https://aka.ms/dotnet-cli"

# Strip out semantic version metadata so it can be cast to `Version`
$existingVersion, $null = (dotnet --version) -split '-'
Assert ([Version]$existingVersion -ge [Version]("6.0")) ".NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
[Version]$existingVersion, $null = (dotnet --version) -split " " -split "-"
Assert ($existingVersion -ge [Version]("8.0")) ".NET SDK 8.0 or higher is required, please update it: https://aka.ms/dotnet-cli"

Write-Host "Using dotnet v$(dotnet --version) at path $((Get-Command dotnet).Source)" -ForegroundColor Green
}
Expand Down Expand Up @@ -157,63 +158,103 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
}

Task SetupHelpForTests {
if (-not (Get-Help Microsoft.PowerShell.Management\Get-Process).Description) {
Write-Host "Updating help for tests."
Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser
}
# TODO: Check if it must be updated in a compatible way!
Write-Host "Updating help for tests."
Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser
}

Task Build FindDotNet, CreateBuildInfo, {
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS72 }
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetFramework.Standard }
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS72 }

if (-not $script:IsNix) {
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS51 }
}

# Build PowerShellEditorServices.VSCode module
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard }
Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetFramework.Standard }
}

Task Test TestServer, TestE2E, TestConstrainedLanguageMode
# The concise set of tests (for pull requests)
Task Test TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell

Task TestServer SetupHelpForTests, TestServerWinPS, TestServerPS72, TestServerPS73
# Every combination of tests (for main branch)
Task TestFull Test, TestPS73, TestPS72, TestE2EPwshCLM, TestE2EPowerShellCLM

Task TestE2E SetupHelpForTests, TestE2EPwsh, TestE2EWinPS
Task TestPS74 Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 }
}

Task TestServerWinPS -If (-not $script:IsNix) Build, {
Task TestPS73 Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
# that is debuggable! If architecture is added, the assembly path gets an
# additional folder, necesstiating fixes to find the commands definition
# file and test files.
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS73 }
}

Task TestServerPS72 Build, {
Task TestPS72 Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS72 }
}

Task TestServerPS73 Build, {
Task TestPS51 -If (-not $script:IsNix) Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
# that is debuggable! If architecture is added, the assembly path gets an
# additional folder, necessitating fixes to find the commands definition
# file and test files.
try {
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
# Inheriting the module path for powershell.exe breaks things!
$originalModulePath = $env:PSModulePath
$env:PSModulePath = ""
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS51 }
} finally {
$env:PSModulePath = $originalModulePath
}
}

Task TestE2EPwsh Build, {
# NOTE: The framework for the E2E tests applies to the mock client, and so
# should just be the latest supported framework.
Task TestE2EPwsh Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "pwsh"
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 }
}

Task TestE2EWinPS -If (-not $script:IsNix) Build, {
Task TestE2EPowerShell -If (-not $script:IsNix) Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "powershell"
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
try {
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
# Inheriting the module path for powershell.exe breaks things!
$originalModulePath = $env:PSModulePath
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 }
} finally {
$env:PSModulePath = $originalModulePath
}
}

Task TestE2EPwshCLM -If (-not $script:IsNix) Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "pwsh"

if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) {
Write-Warning "Skipping Constrained Language Mode tests as they must be ran in an elevated process."
return
}

try {
Write-Host "Running end-to-end tests in Constrained Language Mode."
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine)
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 }
} finally {
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine)
}
}

Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, {
Task TestE2EPowerShellCLM -If (-not $script:IsNix) Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\
$env:PWSH_EXE_NAME = "powershell"

if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) {
Write-Warning "Skipping Constrained Language Mode tests as they must be ran in an elevated process."
Expand All @@ -223,9 +264,13 @@ Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, {
try {
Write-Host "Running end-to-end tests in Constrained Language Mode."
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine)
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
# Inheriting the module path for powershell.exe breaks things!
$originalModulePath = $env:PSModulePath
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 }
} finally {
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine)
$env:PSModulePath = $originalModulePath
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PowerShell Editor Services

[![Build Status](https://dev.azure.com/powershell/PowerShellEditorServices/_apis/build/status/PowerShellEditorServices-ci?branchName=main)](https://dev.azure.com/powershell/PowerShellEditorServices/_build/latest?definitionId=57&branchName=main)
[![CI Tests](https://github.com/PowerShell/PowerShellEditorServices/actions/workflows/ci-test.yml/badge.svg)](https://github.com/PowerShell/PowerShellEditorServices/actions/workflows/ci-test.yml)
[![Discord](https://img.shields.io/discord/180528040881815552.svg?label=%23vscode&logo=discord&logoColor=white)](https://aka.ms/psdiscord)
[![Join the chat at https://gitter.im/PowerShell/PowerShellEditorServices](https://badges.gitter.im/PowerShell/PowerShellEditorServices.svg)](https://gitter.im/PowerShell/PowerShellEditorServices?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.14",
"version": "8.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
7 changes: 6 additions & 1 deletion src/PowerShellEditorServices/Utility/VersionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ internal static class VersionUtils
public static bool IsPS5 { get; } = PSVersion.Major == 5;

/// <summary>
/// True if we are running in PowerShell 7, false otherwise.
/// True if we are running in PowerShell 7 or greater, false otherwise.
/// </summary>
public static bool IsPS7OrGreater { get; } = PSVersion.Major >= 7;

/// <summary>
/// True if we are running in PowerShell 7.4, false otherwise.
/// </summary>
public static bool IsPS74 { get; } = PSVersion.Major == 7 && PSVersion.Minor == 4;

/// <summary>
/// True if we are running on Windows, false otherwise.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ PowerShellVersion details
if (PwshExe == "powershell")
{
Assert.Equal("Desktop", details.Edition);
Assert.StartsWith("5", details.Version);
}
else
{
Assert.Equal("Core", details.Edition);
Assert.StartsWith("7", details.Version);
}
}

Expand Down Expand Up @@ -1060,7 +1062,14 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync()
[SkippableFact]
public async Task CanRequestCompletionsAndHandleExceptions()
{
Skip.If(PsesStdioProcess.IsWindowsPowerShell, "This is a temporary bug in PowerShell 7, the fix is making its way upstream.");
PowerShellVersion details
= await PsesLanguageClient
.SendRequest("powerShell/getVersion", new GetVersionParams())
.Returning<PowerShellVersion>(CancellationToken.None);

Skip.IfNot(details.Version.StartsWith("7.2") || details.Version.StartsWith("7.3"),
"This is a bug in PowerShell 7.2 and 7.3, fixed in 7.4");

string filePath = NewTestFile(@"
@() | ForEach-Object {
if ($false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace PowerShellEditorServices.Test.E2E
{
/// <summary>
/// A <see cref="ServerProcess"/> is responsible for launching or attaching to a language server, providing access to its input and output streams, and tracking its lifetime.
/// A <see cref="ServerProcess"/> is responsible for launching or attaching to a language server, providing access to its input and output streams, and tracking its lifetime.
/// </summary>
public class PsesStdioProcess : StdioServerProcess
{
Expand All @@ -21,17 +21,14 @@ public class PsesStdioProcess : StdioServerProcess
#region private static or constants members

private static readonly string s_bundledModulePath = new FileInfo(Path.Combine(
s_binDir,
"..", "..", "..", "..", "..",
"module")).FullName;
s_binDir, "..", "..", "..", "..", "..", "module")).FullName;

private static readonly string s_sessionDetailsPath = Path.Combine(
s_binDir,
$"pses_test_sessiondetails_{Path.GetRandomFileName()}");
s_binDir, $"pses_test_sessiondetails_{Path.GetRandomFileName()}");

private static readonly string s_logPath = Path.Combine(
Environment.GetEnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY") ?? s_binDir,
$"pses_test_logs_{Path.GetRandomFileName()}");
s_binDir, $"pses_test_logs_{Path.GetRandomFileName()}");

private const string s_logLevel = "Diagnostic";
private static readonly string[] s_featureFlags = { "PSReadLine" };
private const string s_hostName = "TestHost";
Expand Down
Loading