From e2a1bb120d3e78d1d22b3497f00848da781ff401 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 20:50:38 -0700 Subject: [PATCH 01/14] move tests to PS7 and PS7.1 --- PowerShellEditorServices.build.ps1 | 35 ++++++++++++------- global.json | 2 +- .../Utility/VersionUtils.cs | 2 +- .../Completion/CompleteCommandFromModule.cs | 3 +- .../Language/LanguageServiceTests.cs | 13 +++++-- .../PowerShellEditorServices.Test.csproj | 11 +++--- .../Session/WorkspaceTests.cs | 2 +- .../Utility/VersionUtilsTests.cs | 24 +++++++++++++ 8 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 test/PowerShellEditorServices.Test/Utility/VersionUtilsTests.cs diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 89c44260f..3a1efa22a 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -25,12 +25,14 @@ $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditor $script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix) $script:NetRuntime = @{ - Core = 'netcoreapp2.1' + PS6 = 'netcoreapp2.1' + PS7 = 'netcoreapp3.1' + PS71 = 'net5.0' Desktop = 'net461' Standard = 'netstandard2.0' } -$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.Core)/publish" +$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS6)/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" @@ -52,7 +54,7 @@ function Invoke-WithCreateDefaultHook { } } -task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestE2E { +task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E { $dotnetPath = "$PSScriptRoot/.dotnet" $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } @@ -228,7 +230,7 @@ task SetupHelpForTests -Before Test { task Build BinClean,{ exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } - exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Core } + exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS6 } if (-not $script:IsUnix) { exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } @@ -245,15 +247,24 @@ function DotNetTestFilter { task Test TestServer,TestE2E -task TestServer { +task TestServer TestServerWinPS,TestServerPS7,TestServerPS71 + +task TestServerWinPS -If (-not $script:IsUnix) { Set-Location .\test\PowerShellEditorServices.Test\ + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } +} - if (-not $script:IsUnix) { - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } +task TestServerPS7 { + Set-Location .\test\PowerShellEditorServices.Test\ + Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) } } +} +task TestServerPS71 { + Set-Location .\test\PowerShellEditorServices.Test\ Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) } } } @@ -265,21 +276,21 @@ task TestHost { exec { & $script:dotnetExe test -f $script:NetRuntime.Desktop (DotNetTestFilter) } } - exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.Core } - exec { & $script:dotnetExe test -f $script:NetRuntime.Core (DotNetTestFilter) } + exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS6 } + exec { & $script:dotnetExe test -f $script:NetRuntime.PS6 (DotNetTestFilter) } } task TestE2E { Set-Location .\test\PowerShellEditorServices.Test.E2E\ $env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" } - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS6 (DotNetTestFilter) } # Run E2E tests in ConstrainedLanguage mode. if (!$script:IsUnix) { try { [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine); - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Core (DotNetTestFilter) } + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS6 (DotNetTestFilter) } } finally { [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine); } diff --git a/global.json b/global.json index 0fe63c97e..e0d1222f5 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.804" + "version": "5.0.100-preview.6.20318.15" } } diff --git a/src/PowerShellEditorServices/Utility/VersionUtils.cs b/src/PowerShellEditorServices/Utility/VersionUtils.cs index 3dddd7914..e2c19ab03 100644 --- a/src/PowerShellEditorServices/Utility/VersionUtils.cs +++ b/src/PowerShellEditorServices/Utility/VersionUtils.cs @@ -17,7 +17,7 @@ internal static class VersionUtils /// /// True if we are running on .NET Core, false otherwise. /// - public static bool IsNetCore { get; } = RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal); + public static bool IsNetCore { get; } = !RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal); /// /// Gets the Version of PowerShell being used. diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs index e850a3590..8259d636d 100644 --- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs +++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandFromModule.cs @@ -30,7 +30,8 @@ internal class CompleteCommandFromModule CompletionDetails.Create( "Get-Random", CompletionType.Command, - string.Join(Environment.NewLine + Environment.NewLine, s_getRandomParamSets) + string.Join(Environment.NewLine + Environment.NewLine, s_getRandomParamSets), + listItemText: "Get-Random" ); } } diff --git a/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs b/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs index 487a4672f..346fdd841 100644 --- a/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs @@ -78,9 +78,18 @@ await this.GetCompletionResults( CompleteCommandFromModule.SourceDetails); Assert.NotEmpty(completionResults.Completions); + Assert.Equal( - CompleteCommandFromModule.ExpectedCompletion, - completionResults.Completions[0]); + CompleteCommandFromModule.ExpectedCompletion.CompletionText, + completionResults.Completions[0].CompletionText + ); + + Assert.Equal( + CompleteCommandFromModule.ExpectedCompletion.CompletionType, + completionResults.Completions[0].CompletionType + ); + + Assert.NotNull(completionResults.Completions[0].ToolTipText); } [Trait("Category", "Completions")] diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 8f84b1504..d4895a636 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net461 + net5.0;netcoreapp3.1;net461 Microsoft.PowerShell.EditorServices.Test @@ -12,8 +12,11 @@ - - + + + + + @@ -33,7 +36,7 @@ PreserveNewest - + $(DefineConstants);CoreCLR diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 5b15539a8..73105a75c 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -97,7 +97,7 @@ public void CanRecurseDirectoryTree() ignoreReparsePoints: s_defaultIgnoreReparsePoints ); - if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Core")) + if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework")) { // .Net Core doesn't appear to use the same three letter pattern matching rule although the docs // suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1' diff --git a/test/PowerShellEditorServices.Test/Utility/VersionUtilsTests.cs b/test/PowerShellEditorServices.Test/Utility/VersionUtilsTests.cs new file mode 100644 index 000000000..403afc2a8 --- /dev/null +++ b/test/PowerShellEditorServices.Test/Utility/VersionUtilsTests.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.PowerShell.EditorServices.Utility; +using Xunit; + +namespace Microsoft.PowerShell.EditorServices.Test.Utility +{ + public class VersionUtilsTests + { + [Trait("Category", "VersionUtils")] + [Fact] + public void IsNetCoreTest() + { +#if CoreCLR + Assert.True(VersionUtils.IsNetCore); +#else + Assert.False(VersionUtils.IsNetCore); +#endif + } + } +} From d20d86046b001980899039f6f35e607a0eed3310 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 22:12:11 -0700 Subject: [PATCH 02/14] fix up build script --- PowerShellEditorServices.build.ps1 | 98 ++++++++++++------- .../PowerShellEditorServices.Test.csproj | 5 +- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 3a1efa22a..7e0038137 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -20,19 +20,22 @@ param( $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows $script:RequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version +$script:AdditionalSdkVersions = @( + '3.1' +) $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") $script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix) $script:NetRuntime = @{ - PS6 = 'netcoreapp2.1' + PS62 = 'netcoreapp2.1' PS7 = 'netcoreapp3.1' PS71 = 'net5.0' Desktop = 'net461' Standard = 'netstandard2.0' } -$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS6)/publish" +$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS62)/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" @@ -54,7 +57,47 @@ function Invoke-WithCreateDefaultHook { } } -task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E { +function Install-Dotnet { + param ( + $Version, + $Channel + ) + + Write-Host "`n### Installing .NET CLI $Version...`n" -ForegroundColor Green + + # The install script is platform-specific + $installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" } + + # Download the official installation script and run it + $installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" + Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath + $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" + + $args = if($Version) { + '-Version' + $Version + } elseif ($Channel) { + '-Channel' + $Channel + } else { + '-JSonFile', + (Join-Path $PSScriptRoot 'global.json') + } + + if ($script:IsUnix) { + chmod +x $installScriptPath + } + + & $installScriptPath @args -InstallDir "$env:DOTNET_INSTALL_DIR" + + if ($script:IsUnix) { + $env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH + } + + Write-Host "`n### Installation complete." -ForegroundColor Green +} + +task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS62, TestServerPS7, TestServerPS71, TestE2E { $dotnetPath = "$PSScriptRoot/.dotnet" $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } @@ -87,31 +130,11 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, } if ($script:dotnetExe -eq $null) { - - Write-Host "`n### Installing .NET CLI $script:RequiredSdkVersion...`n" -ForegroundColor Green - - # The install script is platform-specific - $installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" } - - # Download the official installation script and run it - $installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath - $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" - - if (!$script:IsUnix) { - & $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR" - } - else { - & /bin/bash $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR" - $env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH - } - - Write-Host "`n### Installation complete." -ForegroundColor Green - $script:dotnetExe = $originalDotnetExePath + Install-Dotnet } # This variable is used internally by 'dotnet' to know where it's installed - $script:dotnetExe = Resolve-Path $script:dotnetExe + $script:dotnetExe = Resolve-Path $originalDotNetExePath if (!$env:DOTNET_INSTALL_DIR) { $dotnetExeDir = [System.IO.Path]::GetDirectoryName($script:dotnetExe) @@ -230,7 +253,7 @@ task SetupHelpForTests -Before Test { task Build BinClean,{ exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard } - exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS6 } + exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS62 } if (-not $script:IsUnix) { exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop } @@ -247,14 +270,23 @@ function DotNetTestFilter { task Test TestServer,TestE2E -task TestServer TestServerWinPS,TestServerPS7,TestServerPS71 +task TestServer TestServerWinPS,TestServerPS62,TestServerPS7,TestServerPS71 task TestServerWinPS -If (-not $script:IsUnix) { Set-Location .\test\PowerShellEditorServices.Test\ exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } } +task TestServerPS62 { + Install-Dotnet -Channel 2.1 + Set-Location .\test\PowerShellEditorServices.Test\ + Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } + } +} + task TestServerPS7 { + Install-Dotnet -Channel 3.1 Set-Location .\test\PowerShellEditorServices.Test\ Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) } @@ -276,21 +308,21 @@ task TestHost { exec { & $script:dotnetExe test -f $script:NetRuntime.Desktop (DotNetTestFilter) } } - exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS6 } - exec { & $script:dotnetExe test -f $script:NetRuntime.PS6 (DotNetTestFilter) } + exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS62 } + exec { & $script:dotnetExe test -f $script:NetRuntime.PS62 (DotNetTestFilter) } } task TestE2E { Set-Location .\test\PowerShellEditorServices.Test.E2E\ $env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" } - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS6 (DotNetTestFilter) } + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } # Run E2E tests in ConstrainedLanguage mode. if (!$script:IsUnix) { try { [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine); - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS6 (DotNetTestFilter) } + exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } } finally { [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine); } @@ -314,10 +346,6 @@ task LayoutModule -After Build { # Copy Third Party Notices.txt to module folder Copy-Item -Force -Path "$PSScriptRoot\Third Party Notices.txt" -Destination $psesOutputPath - # Copy UnixConsoleEcho native libraries - Copy-Item -Path "$script:PsesOutput/runtimes/osx-64/native/*" -Destination $psesDepsPath -Force - Copy-Item -Path "$script:PsesOutput/runtimes/linux-64/native/*" -Destination $psesDepsPath -Force - # Assemble PSES module $includedDlls = [System.Collections.Generic.HashSet[string]]::new() diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index d4895a636..59fa2a989 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -18,6 +18,9 @@ + + + @@ -36,7 +39,7 @@ PreserveNewest - + $(DefineConstants);CoreCLR From 424c7f0eaccb8c279b77de7a8597ce3de89c94aa Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 22:21:15 -0700 Subject: [PATCH 03/14] remove 6.2 --- PowerShellEditorServices.build.ps1 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 7e0038137..b23f19bed 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -97,7 +97,7 @@ function Install-Dotnet { Write-Host "`n### Installation complete." -ForegroundColor Green } -task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS62, TestServerPS7, TestServerPS71, TestE2E { +task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E { $dotnetPath = "$PSScriptRoot/.dotnet" $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } @@ -270,21 +270,13 @@ function DotNetTestFilter { task Test TestServer,TestE2E -task TestServer TestServerWinPS,TestServerPS62,TestServerPS7,TestServerPS71 +task TestServer TestServerWinPS,TestServerPS7,TestServerPS71 task TestServerWinPS -If (-not $script:IsUnix) { Set-Location .\test\PowerShellEditorServices.Test\ exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) } } -task TestServerPS62 { - Install-Dotnet -Channel 2.1 - Set-Location .\test\PowerShellEditorServices.Test\ - Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { - exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) } - } -} - task TestServerPS7 { Install-Dotnet -Channel 3.1 Set-Location .\test\PowerShellEditorServices.Test\ From 71aab29fcd3a3dd86718ec3c568cd6542ef67fda Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 22:31:19 -0700 Subject: [PATCH 04/14] change global.json back --- PowerShellEditorServices.build.ps1 | 1 + global.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index b23f19bed..80b426ee5 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -286,6 +286,7 @@ task TestServerPS7 { } task TestServerPS71 { + Install-Dotnet -Channel 5.0 Set-Location .\test\PowerShellEditorServices.Test\ Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) } diff --git a/global.json b/global.json index e0d1222f5..0fe63c97e 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "5.0.100-preview.6.20318.15" + "version": "2.1.804" } } From 302d603b41322e59527d6d903d620ce5a7eba373 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 22:41:04 -0700 Subject: [PATCH 05/14] remove using dotnet already installed --- PowerShellEditorServices.build.ps1 | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 80b426ee5..801a9edea 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -101,40 +101,13 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, $dotnetPath = "$PSScriptRoot/.dotnet" $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } - $originalDotNetExePath = $dotnetExePath if (!(Test-Path $dotnetExePath)) { - $installedDotnet = Get-Command dotnet -ErrorAction Ignore - if ($installedDotnet) { - $dotnetExePath = $installedDotnet.Source - } - else { - $dotnetExePath = $null - } - } - - # Make sure the dotnet we found is the right version - if ($dotnetExePath) { - # dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead. - if ((& $dotnetExePath --list-sdks | ForEach-Object { $_.Split()[0] } ) -contains $script:RequiredSdkVersion) { - $script:dotnetExe = $dotnetExePath - } - else { - # Clear the path so that we invoke installation - $script:dotnetExe = $null - } - } - else { - # Clear the path so that we invoke installation - $script:dotnetExe = $null - } - - if ($script:dotnetExe -eq $null) { Install-Dotnet } # This variable is used internally by 'dotnet' to know where it's installed - $script:dotnetExe = Resolve-Path $originalDotNetExePath + $script:dotnetExe = Resolve-Path $dotnetExePath if (!$env:DOTNET_INSTALL_DIR) { $dotnetExeDir = [System.IO.Path]::GetDirectoryName($script:dotnetExe) From 257d0e4f9f452e39f4c130f5594aa0d31ef8080f Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 22:43:45 -0700 Subject: [PATCH 06/14] install ahead of time --- PowerShellEditorServices.build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 801a9edea..8e1eb71af 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -104,6 +104,8 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, if (!(Test-Path $dotnetExePath)) { Install-Dotnet + Install-Dotnet -Channel 3.1 + Install-Dotnet -Channel 5.0 } # This variable is used internally by 'dotnet' to know where it's installed @@ -251,7 +253,6 @@ task TestServerWinPS -If (-not $script:IsUnix) { } task TestServerPS7 { - Install-Dotnet -Channel 3.1 Set-Location .\test\PowerShellEditorServices.Test\ Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) } @@ -259,7 +260,6 @@ task TestServerPS7 { } task TestServerPS71 { - Install-Dotnet -Channel 5.0 Set-Location .\test\PowerShellEditorServices.Test\ Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath { exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) } From 052b89f5673e2ef88ed80dd17cd347851df56bd3 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 23:02:12 -0700 Subject: [PATCH 07/14] remove global.json --- PowerShellEditorServices.build.ps1 | 7 +++---- global.json | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 global.json diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 8e1eb71af..43718d66d 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -19,7 +19,6 @@ param( #Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"} $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows -$script:RequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version $script:AdditionalSdkVersions = @( '3.1' ) @@ -103,9 +102,9 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, $dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } if (!(Test-Path $dotnetExePath)) { - Install-Dotnet - Install-Dotnet -Channel 3.1 - Install-Dotnet -Channel 5.0 + Install-Dotnet -Channel '2.1' + Install-Dotnet -Channel '3.1' + Install-Dotnet -Version '5.0.100-preview.6.20318.15' } # This variable is used internally by 'dotnet' to know where it's installed diff --git a/global.json b/global.json deleted file mode 100644 index 0fe63c97e..000000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "2.1.804" - } -} From 00678bbb399b3a07ff9276914d370f47ba799b6f Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 29 Jun 2020 23:06:55 -0700 Subject: [PATCH 08/14] continueOnError --- .vsts-ci/templates/ci-general.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index f7e20037c..34b81b7c1 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -14,6 +14,7 @@ steps: # Using `prependpath` to update the PATH just for this build. Write-Host "##vso[task.prependpath]$powerShellPath" displayName: Install PowerShell Daily + continueOnError: true - pwsh: '$PSVersionTable' displayName: Display PowerShell version information From 276214694cdf27fb4850f732d766dee6d761d0a0 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Mon, 29 Jun 2020 23:37:08 -0700 Subject: [PATCH 09/14] use different url --- PowerShellEditorServices.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 43718d66d..afc946308 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -69,7 +69,7 @@ function Install-Dotnet { # Download the official installation script and run it $installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath + Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" $args = if($Version) { From f2c11b2007ced8084d30dfee5e68c263e174042c Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 30 Jun 2020 09:10:32 -0700 Subject: [PATCH 10/14] test new rcedit --- .vsts-ci/templates/ci-general.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 34b81b7c1..57c48daef 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -7,7 +7,7 @@ steps: # Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up. $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' - Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/97cef1df61690f5405904896a173e829c06c305b/tools/install-powershell.ps1 -OutFile ./install-powershell.ps1 ./install-powershell.ps1 -Destination $powerShellPath -Daily From f1e005f160165db4b64a29641e6896cc5e86a9c2 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 30 Jun 2020 09:19:45 -0700 Subject: [PATCH 11/14] different splat mechanic --- PowerShellEditorServices.build.ps1 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 43718d66d..948edf99f 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -72,22 +72,31 @@ function Install-Dotnet { Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/sdk/master/scripts/obtain/dotnet-install.$installScriptExt" -OutFile $installScriptPath $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" - $args = if($Version) { - '-Version' - $Version - } elseif ($Channel) { - '-Channel' - $Channel + $splat = if ($script:IsUnix) { + if($Version) { + '-Version' + $Version + } else { + '-Channel' + $Channel + } } else { - '-JSonFile', - (Join-Path $PSScriptRoot 'global.json') + if($Version) { + @{ + Version = $Version + } + } else { + @{ + Channel = $Channel + } + } } if ($script:IsUnix) { chmod +x $installScriptPath } - & $installScriptPath @args -InstallDir "$env:DOTNET_INSTALL_DIR" + & $installScriptPath @splat -InstallDir "$env:DOTNET_INSTALL_DIR" if ($script:IsUnix) { $env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH From 0f69723b4cb01ca28fae640e580f3d26c8cc4bcc Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 30 Jun 2020 09:24:32 -0700 Subject: [PATCH 12/14] move back to aka --- .vsts-ci/templates/ci-general.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 57c48daef..34b81b7c1 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -7,7 +7,7 @@ steps: # Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up. $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' - Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/97cef1df61690f5405904896a173e829c06c305b/tools/install-powershell.ps1 -OutFile ./install-powershell.ps1 + Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1 ./install-powershell.ps1 -Destination $powerShellPath -Daily From 7f359ccd31b1b9371ca37d9025fd752d204f3e96 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 30 Jun 2020 09:48:40 -0700 Subject: [PATCH 13/14] no platform check --- PowerShellEditorServices.build.ps1 | 32 +++++++----------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 6825387be..8010be2f6 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -19,9 +19,6 @@ param( #Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"} $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows -$script:AdditionalSdkVersions = @( - '3.1' -) $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") $script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix) @@ -72,35 +69,20 @@ function Install-Dotnet { Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" - $splat = if ($script:IsUnix) { - if($Version) { - '-Version' - $Version - } else { - '-Channel' - $Channel - } + $paramArr = if($Version) { + '-Version' + $Version } else { - if($Version) { - @{ - Version = $Version - } - } else { - @{ - Channel = $Channel - } - } + '-Channel' + $Channel } if ($script:IsUnix) { chmod +x $installScriptPath } - & $installScriptPath @splat -InstallDir "$env:DOTNET_INSTALL_DIR" - - if ($script:IsUnix) { - $env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH - } + Invoke-Expression "$installScriptPath $paramArr -InstallDir '$env:DOTNET_INSTALL_DIR' -NoPath" + $env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH Write-Host "`n### Installation complete." -ForegroundColor Green } From e51395a23414bd83e2204159fd901fcfb2219120 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 30 Jun 2020 10:15:19 -0700 Subject: [PATCH 14/14] use channel only --- PowerShellEditorServices.build.ps1 | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 8010be2f6..34583f1be 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -55,7 +55,6 @@ function Invoke-WithCreateDefaultHook { function Install-Dotnet { param ( - $Version, $Channel ) @@ -69,19 +68,12 @@ function Install-Dotnet { Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" - $paramArr = if($Version) { - '-Version' - $Version - } else { - '-Channel' - $Channel - } - if ($script:IsUnix) { chmod +x $installScriptPath } - Invoke-Expression "$installScriptPath $paramArr -InstallDir '$env:DOTNET_INSTALL_DIR' -NoPath" + $paramArr = @('-Channel', $Channel, '-InstallDir', "'$env:DOTNET_INSTALL_DIR'", '-NoPath') + Invoke-Expression "$installScriptPath $paramArr" $env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH Write-Host "`n### Installation complete." -ForegroundColor Green @@ -95,7 +87,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, if (!(Test-Path $dotnetExePath)) { Install-Dotnet -Channel '2.1' Install-Dotnet -Channel '3.1' - Install-Dotnet -Version '5.0.100-preview.6.20318.15' + Install-Dotnet -Channel 'release/5.0.1xx-preview6' } # This variable is used internally by 'dotnet' to know where it's installed