From 7c6de9554bceda244bf2b892d0d097c8c2e995be Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 11:11:38 +0000 Subject: [PATCH 01/45] add unix support for installing the .net core sdk on-demand --- tools/appveyor.psm1 | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index cc8e15f81..f6d43102f 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,12 +33,24 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $dotNetCoreSDKVersion = $globalDotJson.sdk.version - # don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77 - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 - .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion - Remove-Item .\dotnet-install.ps1 + if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) { + $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol + try { + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + if ($IsLinux -or $isMacOS) { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh + bash dotnet-install.sh --version $dotNetCoreSDKVersion + [System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH") + } + else { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion + } + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol + Remove-Item .\dotnet-install.* + } } } From 2db348d5a5c8bb5edbfdfb0e7cd0fd231dad5ebb Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 11:31:04 +0000 Subject: [PATCH 02/45] add logging --- tools/appveyor.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index f6d43102f..fef77cf8a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -34,6 +34,7 @@ function Invoke-AppVeyorInstall { $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $dotNetCoreSDKVersion = $globalDotJson.sdk.version if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) { + Write-Verbose -Verbose "Installing required .Net CORE SDK $dotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 From 2cdb89b593c3053f6e1309c1bc2888e2cbb3b6ba Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 15:01:33 +0000 Subject: [PATCH 03/45] update sdk --- README.md | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 849f556c6..902b80ae5 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.401 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.401) or newer patch release +* [.NET Core 2.1.500 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.500) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/global.json b/global.json index 3520291b0..c8f9e01ca 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.401" + "version": "2.1.500" } } From 80c9beb75cfd015b4408509b3ed60ba2800dabe5 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 15:57:07 +0000 Subject: [PATCH 04/45] adapt for dotnet writing to stderr --- tools/appveyor.psm1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index fef77cf8a..21e93173b 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -32,20 +32,22 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json - $dotNetCoreSDKVersion = $globalDotJson.sdk.version - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) { - Write-Verbose -Verbose "Installing required .Net CORE SDK $dotNetCoreSDKVersion" + $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version + # dotnet does not return and writes to stderr if required minor version is not available and higher than 1 + $availablerequiredDotNetCoreSDKVersion = dotnet --version 2> $null + if ($null -ne $availablerequiredDotNetCoreSDKVersion -or -not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion))) { + Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 if ($IsLinux -or $isMacOS) { Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh - bash dotnet-install.sh --version $dotNetCoreSDKVersion + bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion [System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH") } else { Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 - .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion + .\dotnet-install.ps1 -Version $requiredDotNetCoreSDKVersion } } finally { From 45de0e0dea5ce584b61589e8e1fe1b9e055336c2 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 16:09:44 +0000 Subject: [PATCH 05/45] fix parenthesis --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 21e93173b..f4a473d2e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -35,7 +35,7 @@ function Invoke-AppVeyorInstall { $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version # dotnet does not return and writes to stderr if required minor version is not available and higher than 1 $availablerequiredDotNetCoreSDKVersion = dotnet --version 2> $null - if ($null -ne $availablerequiredDotNetCoreSDKVersion -or -not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion))) { + if ($null -ne $availablerequiredDotNetCoreSDKVersion -or -not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From bf50f1d45b4d5f89fc166cc79805e9d06b2f02b8 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 16:19:10 +0000 Subject: [PATCH 06/45] only set protocol if needed and set erroraction to avoid ci failur --- tools/appveyor.psm1 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index f4a473d2e..72457d2fe 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -34,12 +34,21 @@ function Invoke-AppVeyorInstall { $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version # dotnet does not return and writes to stderr if required minor version is not available and higher than 1 - $availablerequiredDotNetCoreSDKVersion = dotnet --version 2> $null + try { + $originalErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + $availablerequiredDotNetCoreSDKVersion = dotnet --version 2> $null + } + finally { + $ErrorActionPreference = $originalErrorActionPreference + } if ($null -ne $availablerequiredDotNetCoreSDKVersion -or -not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + if (-not [Net.ServicePointManager]::SecurityProtocol -match [Net.SecurityProtocolType]::Tls12) { + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + } if ($IsLinux -or $isMacOS) { Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion From 574927c50a636414bd462959f2a538d988fff35c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 16:26:43 +0000 Subject: [PATCH 07/45] try fix nullreferenceexception --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 72457d2fe..f02ee0126 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -42,7 +42,7 @@ function Invoke-AppVeyorInstall { finally { $ErrorActionPreference = $originalErrorActionPreference } - if ($null -ne $availablerequiredDotNetCoreSDKVersion -or -not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion)) { + if ([string]::IsNullOrEmpty($availablerequiredDotNetCoreSDKVersion) -or (-not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion))) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From a282dfe10277aa685e5d634edbc37a17049729c0 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Nov 2018 16:50:54 +0000 Subject: [PATCH 08/45] use use --list-sdks --- tools/appveyor.psm1 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index f02ee0126..e59c50547 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,16 +33,8 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - # dotnet does not return and writes to stderr if required minor version is not available and higher than 1 - try { - $originalErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = 'Continue' - $availablerequiredDotNetCoreSDKVersion = dotnet --version 2> $null - } - finally { - $ErrorActionPreference = $originalErrorActionPreference - } - if ([string]::IsNullOrEmpty($availablerequiredDotNetCoreSDKVersion) -or (-not $availablerequiredDotNetCoreSDKVersion.StartsWith($requiredDotNetCoreSDKVersion))) { + # dotnet --version does not return and writes to stderr if required minor version is not available and higher than 1 -> use --list-sdks + if (-not ((dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From c0c1b18a2832b9b9034b8e383d8cc9e51c16e02f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 08:40:46 +0000 Subject: [PATCH 09/45] use 2.1.403 sdk, which is at least available on Windows --- README.md | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 902b80ae5..69cdb4bad 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.500 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.500) or newer patch release +* [.NET Core 2.1.403 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.403) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/global.json b/global.json index c8f9e01ca..fde1674a6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.500" + "version": "2.1.403" } } From 81d80f5c991ec13072577a8895ffbdb0ddadcd87 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 08:58:39 +0000 Subject: [PATCH 10/45] use erroractionpreference --- tools/appveyor.psm1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index e59c50547..49d0b8bd2 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -34,7 +34,15 @@ function Invoke-AppVeyorInstall { $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version # dotnet --version does not return and writes to stderr if required minor version is not available and higher than 1 -> use --list-sdks - if (-not ((dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion)) { + try { + $originalErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = 'SilentlyContinue' + $dotnetSDKs = dotnet --list-sdks + } + finally { + $ErrorActionPreference = $originalErrorActionPreference + } + if (-not ($dotnetSDKs -match $requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From d6e01f04012dc30ff651f83784fc6066a98a59b3 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 09:00:23 +0000 Subject: [PATCH 11/45] redirect error --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 49d0b8bd2..a7277c83a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -37,7 +37,7 @@ function Invoke-AppVeyorInstall { try { $originalErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' - $dotnetSDKs = dotnet --list-sdks + $dotnetSDKs = dotnet --list-sdks 2> $null } finally { $ErrorActionPreference = $originalErrorActionPreference From 2d7bee3bc61af289183d3b29e504da38fc5bdeb3 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 09:44:47 +0000 Subject: [PATCH 12/45] use continue --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index a7277c83a..952d59b62 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -36,7 +36,7 @@ function Invoke-AppVeyorInstall { # dotnet --version does not return and writes to stderr if required minor version is not available and higher than 1 -> use --list-sdks try { $originalErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = 'SilentlyContinue' + $ErrorActionPreference = 'Continue' $dotnetSDKs = dotnet --list-sdks 2> $null } finally { From 0ba6a416819b5c3104cc80b16108d4348f1ddd4e Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 10:01:06 +0000 Subject: [PATCH 13/45] use 2.1.400 that is available on both windows and linux and revert other changes that would break break wmf4 --- README.md | 2 +- global.json | 2 +- tools/appveyor.psm1 | 11 +---------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 69cdb4bad..785188e4b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.403 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.403) or newer patch release +* [.NET Core 2.1.400 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.400) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/global.json b/global.json index fde1674a6..dd12f3441 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.1.400" } } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 952d59b62..6cc55f13c 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,16 +33,7 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - # dotnet --version does not return and writes to stderr if required minor version is not available and higher than 1 -> use --list-sdks - try { - $originalErrorActionPreference = $ErrorActionPreference - $ErrorActionPreference = 'Continue' - $dotnetSDKs = dotnet --list-sdks 2> $null - } - finally { - $ErrorActionPreference = $originalErrorActionPreference - } - if (-not ($dotnetSDKs -match $requiredDotNetCoreSDKVersion)) { + if (-not ((dotnet --version).StartsWith($requiredDotNetCoreSDKVersion))) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From f33f66c9978922ab7df5786cf234ef217f187a67 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 10:19:38 +0000 Subject: [PATCH 14/45] remove if check that could break wmf4? --- tools/appveyor.psm1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 6cc55f13c..e4c2e0f4b 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -37,9 +37,7 @@ function Invoke-AppVeyorInstall { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { - if (-not [Net.ServicePointManager]::SecurityProtocol -match [Net.SecurityProtocolType]::Tls12) { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 - } + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 if ($IsLinux -or $isMacOS) { Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion From b8cd894bed85e3fe98f5ae3957ad79ce36fed277 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 11:16:55 +0000 Subject: [PATCH 15/45] use --list-sdks --- tools/appveyor.psm1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index e4c2e0f4b..a7f2d9dbc 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,7 +33,8 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - if (-not ((dotnet --version).StartsWith($requiredDotNetCoreSDKVersion))) { + $dotnetSDKs = dotnet --list-sdks 2> $null + if (-not ($dotnetSDKs -match $requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From 330408a3d2d61a815f9f5537dbd81ea6c4a2cc23 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 11:36:56 +0000 Subject: [PATCH 16/45] try different syntax to get wmf4 to work --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index a7f2d9dbc..8c1c7e079 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,7 +33,7 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - $dotnetSDKs = dotnet --list-sdks 2> $null + $dotnetSDKs = & dotnet '--list-sdks' 2> $null if (-not ($dotnetSDKs -match $requiredDotNetCoreSDKVersion)) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol From 4bb85e2750fa1006d5e9d1bb2f3ba9ce57cf5d75 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 11:54:28 +0000 Subject: [PATCH 17/45] disable wmf4 for the moment --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 07c891a40..4b8a9148a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,9 @@ environment: PowerShellEdition: PowerShellCore - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: WindowsPowerShell - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: WindowsPowerShell - PSVersion: 4 + # - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + # PowerShellEdition: WindowsPowerShell + # PSVersion: 4 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore From d4e04364593ff37abadc1e7623a84889eb27ccd7 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 12:16:07 +0000 Subject: [PATCH 18/45] use 2.1.403 and re-enable wmf4 --- README.md | 2 +- appveyor.yml | 6 +++--- global.json | 2 +- tools/appveyor.psm1 | 10 ++++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 785188e4b..69cdb4bad 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.400 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.400) or newer patch release +* [.NET Core 2.1.403 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.403) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/appveyor.yml b/appveyor.yml index 4b8a9148a..07c891a40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,9 @@ environment: PowerShellEdition: PowerShellCore - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: WindowsPowerShell - # - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - # PowerShellEdition: WindowsPowerShell - # PSVersion: 4 + - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + PowerShellEdition: WindowsPowerShell + PSVersion: 4 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore diff --git a/global.json b/global.json index dd12f3441..fde1674a6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.400" + "version": "2.1.403" } } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 8c1c7e079..a15ff9609 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,8 +33,14 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - $dotnetSDKs = & dotnet '--list-sdks' 2> $null - if (-not ($dotnetSDKs -match $requiredDotNetCoreSDKVersion)) { + if ($PSVersionTable.PSVersion.Major -gt 4) { + $requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion + } + else { + # WMF 4 image has old SDK that does not have --list-sdks parameter + $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($dotNetCoreSDKVersion) + } + if (-not $requiredDotNetCoreSDKVersionPresent) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From bd2648a248c55d012c20fc66e0037c145f4a4cb0 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 29 Nov 2018 12:36:48 +0000 Subject: [PATCH 19/45] fix typo (wmf4) --- tools/appveyor.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index a15ff9609..46fc0736a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -38,7 +38,7 @@ function Invoke-AppVeyorInstall { } else { # WMF 4 image has old SDK that does not have --list-sdks parameter - $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($dotNetCoreSDKVersion) + $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion) } if (-not $requiredDotNetCoreSDKVersionPresent) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" From 0172c988ec30751ac70a128f3c92bba9366d4f77 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 15 Dec 2018 11:46:58 +0000 Subject: [PATCH 20/45] use .net core sdk 2.1.502 --- README.md | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69cdb4bad..31d0e4253 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements -* [.NET Core 2.1.403 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.403) or newer patch release +* [.NET Core 2.1.502 SDK](https://www.microsoft.com/net/download/dotnet-core/2.1#sdk-2.1.502) or newer patch release * [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) diff --git a/global.json b/global.json index fde1674a6..d328f8082 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.1.502" } } From 8c48e93e5da0b435d01ada38e76ab343a187f30d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 20 Dec 2018 18:54:38 +0000 Subject: [PATCH 21/45] ignore 5 pester failure on Ubuntu for AppVeyor due Pester/PowerShell bug that happens on AppVeyor environment --- Tests/Documentation/RuleDocumentation.tests.ps1 | 14 +++++++------- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 2 +- Tests/Rules/AvoidUsingAlias.tests.ps1 | 2 +- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Documentation/RuleDocumentation.tests.ps1 b/Tests/Documentation/RuleDocumentation.tests.ps1 index ca41f4819..34c5571d1 100644 --- a/Tests/Documentation/RuleDocumentation.tests.ps1 +++ b/Tests/Documentation/RuleDocumentation.tests.ps1 @@ -35,29 +35,29 @@ Describe "Validate rule documentation files" { $rulesReadmeDiff = Compare-Object -ReferenceObject $rules -DifferenceObject $readmeRules -SyncWindow 25 } - It "Every rule must have a rule documentation file" { + It "Every rule must have a rule documentation file" -Skip:($env:APPVEYOR -and $IsLinux) { $rulesDocsDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every rule documentation file must have a corresponding rule" { + It "Every rule documentation file must have a corresponding rule" -Skip:($env:APPVEYOR -and $IsLinux) { $rulesDocsDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every rule must have an entry in the rule documentation README.md file" { + It "Every rule must have an entry in the rule documentation README.md file" -Skip:($env:APPVEYOR -and $IsLinux) { $rulesReadmeDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every entry in the rule documentation README.md file must correspond to a rule" { + It "Every entry in the rule documentation README.md file must correspond to a rule" -Skip:($env:APPVEYOR -and $IsLinux) { $rulesReadmeDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every entry in the rule documentation README.md file must have a valid link to the documentation file" { + It "Every entry in the rule documentation README.md file must have a valid link to the documentation file" -Skip:($env:APPVEYOR -and $IsLinux) { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link $filePath | Should -Exist } } - - It "Every rule name in the rule documentation README.md file must match the documentation file's basename" { + + It "Every rule name in the rule documentation README.md file must match the documentation file's basename" --Skip:($env:APPVEYOR -and $IsLinux) { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index c43cac665..54742e56c 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -533,7 +533,7 @@ Describe "Test -Fix Switch" { } Describe "Test -EnableExit Switch" { - It "Returns exit code equivalent to number of warnings" { + It "Returns exit code equivalent to number of warnings" -Skip:($env:APPVEYOR -and $IsLinux) { if ($IsCoreCLR) { pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' } diff --git a/Tests/Rules/AvoidUsingAlias.tests.ps1 b/Tests/Rules/AvoidUsingAlias.tests.ps1 index c92748977..359dffd3d 100644 --- a/Tests/Rules/AvoidUsingAlias.tests.ps1 +++ b/Tests/Rules/AvoidUsingAlias.tests.ps1 @@ -95,7 +95,7 @@ Configuration MyDscConfiguration { $violations.Count | Should -Be 1 } - It "honors the whitelist in a case-insensitive manner" { + It "honors the whitelist in a case-insensitive manner" -Skip:($env:APPVEYOR -and $IsLinux) { $violations = Invoke-ScriptAnalyzer -ScriptDefinition "CD" -Settings $settings -IncludeRule $violationName $violations.Count | Should -Be 0 } diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index 45ebef3d9..fd5b2b8ef 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -13,12 +13,12 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') } Describe "StandardDSCFunctionsInResource" { - Context "When there are violations" { - It "has 1 missing standard DSC functions violation" { + Context "When there are violations" { + It "has 1 missing standard DSC functions violation" -Skip:($env:APPVEYOR -and $IsLinux) { $violations.Count | Should -Be 1 } - It "has the correct description message" { + It "has the correct description message" -Skip:($env:APPVEYOR -and $IsLinux) { $violations[0].Message | Should -Match $violationMessage } } From 61c4d5940fbdbd1ca6d87731d8ff19ee597caf1d Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Thu, 20 Dec 2018 19:33:21 +0000 Subject: [PATCH 22/45] Fix typo --- Tests/Documentation/RuleDocumentation.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Documentation/RuleDocumentation.tests.ps1 b/Tests/Documentation/RuleDocumentation.tests.ps1 index 34c5571d1..986c0f8da 100644 --- a/Tests/Documentation/RuleDocumentation.tests.ps1 +++ b/Tests/Documentation/RuleDocumentation.tests.ps1 @@ -57,7 +57,7 @@ Describe "Validate rule documentation files" { } } - It "Every rule name in the rule documentation README.md file must match the documentation file's basename" --Skip:($env:APPVEYOR -and $IsLinux) { + It "Every rule name in the rule documentation README.md file must match the documentation file's basename" -Skip:($env:APPVEYOR -and $IsLinux) { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link From 064683f572598ff6b7a04bd1b8aaa6382862659a Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 20 Dec 2018 20:47:25 +0000 Subject: [PATCH 23/45] add more skip statements for failing appveyor tests --- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 20 +++++++++---------- Tests/Rules/AvoidUsingAlias.tests.ps1 | 2 +- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index 54742e56c..86c206056 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -181,15 +181,15 @@ Describe "Test Path" { $numFilesResult | Should -Be $numFilesExpected } } - + Context "When piping in files" { It "Can be piped in from a string" { $piped = ("$directory\TestScript.ps1" | Invoke-ScriptAnalyzer) $explicit = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 - + $piped.Count | Should Be $explicit.Count } - + It "Can be piped from Get-ChildItem" { $piped = ( Get-ChildItem -Path $directory -Filter TestTestPath*.ps1 | Invoke-ScriptAnalyzer) $explicit = Invoke-ScriptAnalyzer -Path $directory\TestTestPath*.ps1 @@ -410,7 +410,7 @@ Describe "Test CustomizedRulePath" { Pop-Location } } - + It "resolves rule preset when passed in via pipeline" { $warnings = 'CodeFormattingStroustrup' | ForEach-Object { Invoke-ScriptAnalyzer -ScriptDefinition 'if ($true){}' -Settings $_} @@ -545,25 +545,25 @@ Describe "Test -EnableExit Switch" { Describe "-ReportSummary switch" { $reportSummaryFor1Warning = '*1 rule violation found. Severity distribution: Error = 0, Warning = 1, Information = 0*' - It "prints the correct report summary using the -NoReportSummary switch" { + It "prints the correct report summary using the -NoReportSummary switch" -Skip:($env:APPVEYOR -and $IsLinux) { if ($IsCoreCLR) { $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } else { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } - - "$result" | Should -BeLike $reportSummaryFor1Warning + + "$result" | Should -BeLike $reportSummaryFor1Warning } - It "does not print the report summary when not using -NoReportSummary switch" { + It "does not print the report summary when not using -NoReportSummary switch" -Skip:($env:APPVEYOR -and $IsLinux) { if ($IsCoreCLR) { $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci' } else { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' } - - "$result" | Should -Not -BeLike $reportSummaryFor1Warning + + "$result" | Should -Not -BeLike $reportSummaryFor1Warning } } diff --git a/Tests/Rules/AvoidUsingAlias.tests.ps1 b/Tests/Rules/AvoidUsingAlias.tests.ps1 index 359dffd3d..dcfb3e71f 100644 --- a/Tests/Rules/AvoidUsingAlias.tests.ps1 +++ b/Tests/Rules/AvoidUsingAlias.tests.ps1 @@ -100,7 +100,7 @@ Configuration MyDscConfiguration { $violations.Count | Should -Be 0 } - It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -skip:(-not ($IsLinux -or $IsMacOS)) { + It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -Skip:(-not ($IsLinux -or $IsMacOS) -or ($env:APPVEYOR -and $IsLinux)) { $violations = Invoke-ScriptAnalyzer -ScriptDefinition 'date' | Where-Object { $_.RuleName -eq $violationName } $violations.Count | Should -Be 0 } diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index fd5b2b8ef..4e26fa5dc 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -24,7 +24,7 @@ Describe "StandardDSCFunctionsInResource" { } Context "When there are no violations" { - It "returns no violations" { + It "returns no violations" -Skip:($env:APPVEYOR -and $IsLinux) { $noViolations.Count | Should -Be 0 } } From 6b17c2b988b3f995a75b44e052d0767c2b671107 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 29 Dec 2018 20:58:18 +0000 Subject: [PATCH 24/45] Revert "add more skip statements for failing appveyor tests" This reverts commit 064683f572598ff6b7a04bd1b8aaa6382862659a. --- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 20 +++++++++---------- Tests/Rules/AvoidUsingAlias.tests.ps1 | 2 +- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index 86c206056..54742e56c 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -181,15 +181,15 @@ Describe "Test Path" { $numFilesResult | Should -Be $numFilesExpected } } - + Context "When piping in files" { It "Can be piped in from a string" { $piped = ("$directory\TestScript.ps1" | Invoke-ScriptAnalyzer) $explicit = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 - + $piped.Count | Should Be $explicit.Count } - + It "Can be piped from Get-ChildItem" { $piped = ( Get-ChildItem -Path $directory -Filter TestTestPath*.ps1 | Invoke-ScriptAnalyzer) $explicit = Invoke-ScriptAnalyzer -Path $directory\TestTestPath*.ps1 @@ -410,7 +410,7 @@ Describe "Test CustomizedRulePath" { Pop-Location } } - + It "resolves rule preset when passed in via pipeline" { $warnings = 'CodeFormattingStroustrup' | ForEach-Object { Invoke-ScriptAnalyzer -ScriptDefinition 'if ($true){}' -Settings $_} @@ -545,25 +545,25 @@ Describe "Test -EnableExit Switch" { Describe "-ReportSummary switch" { $reportSummaryFor1Warning = '*1 rule violation found. Severity distribution: Error = 0, Warning = 1, Information = 0*' - It "prints the correct report summary using the -NoReportSummary switch" -Skip:($env:APPVEYOR -and $IsLinux) { + It "prints the correct report summary using the -NoReportSummary switch" { if ($IsCoreCLR) { $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } else { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } - - "$result" | Should -BeLike $reportSummaryFor1Warning + + "$result" | Should -BeLike $reportSummaryFor1Warning } - It "does not print the report summary when not using -NoReportSummary switch" -Skip:($env:APPVEYOR -and $IsLinux) { + It "does not print the report summary when not using -NoReportSummary switch" { if ($IsCoreCLR) { $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci' } else { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' } - - "$result" | Should -Not -BeLike $reportSummaryFor1Warning + + "$result" | Should -Not -BeLike $reportSummaryFor1Warning } } diff --git a/Tests/Rules/AvoidUsingAlias.tests.ps1 b/Tests/Rules/AvoidUsingAlias.tests.ps1 index dcfb3e71f..359dffd3d 100644 --- a/Tests/Rules/AvoidUsingAlias.tests.ps1 +++ b/Tests/Rules/AvoidUsingAlias.tests.ps1 @@ -100,7 +100,7 @@ Configuration MyDscConfiguration { $violations.Count | Should -Be 0 } - It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -Skip:(-not ($IsLinux -or $IsMacOS) -or ($env:APPVEYOR -and $IsLinux)) { + It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -skip:(-not ($IsLinux -or $IsMacOS)) { $violations = Invoke-ScriptAnalyzer -ScriptDefinition 'date' | Where-Object { $_.RuleName -eq $violationName } $violations.Count | Should -Be 0 } diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index 4e26fa5dc..fd5b2b8ef 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -24,7 +24,7 @@ Describe "StandardDSCFunctionsInResource" { } Context "When there are no violations" { - It "returns no violations" -Skip:($env:APPVEYOR -and $IsLinux) { + It "returns no violations" { $noViolations.Count | Should -Be 0 } } From 5789ea1cd3d7c6700bab584ca34819f95580138a Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 29 Dec 2018 20:59:03 +0000 Subject: [PATCH 25/45] Revert "Fix typo" This reverts commit 61c4d5940fbdbd1ca6d87731d8ff19ee597caf1d. --- Tests/Documentation/RuleDocumentation.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Documentation/RuleDocumentation.tests.ps1 b/Tests/Documentation/RuleDocumentation.tests.ps1 index 986c0f8da..34c5571d1 100644 --- a/Tests/Documentation/RuleDocumentation.tests.ps1 +++ b/Tests/Documentation/RuleDocumentation.tests.ps1 @@ -57,7 +57,7 @@ Describe "Validate rule documentation files" { } } - It "Every rule name in the rule documentation README.md file must match the documentation file's basename" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every rule name in the rule documentation README.md file must match the documentation file's basename" --Skip:($env:APPVEYOR -and $IsLinux) { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link From f4e44418009eeb508fa33484e52b7292472c663d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 29 Dec 2018 20:59:22 +0000 Subject: [PATCH 26/45] Revert "ignore 5 pester failure on Ubuntu for AppVeyor due Pester/PowerShell bug that happens on AppVeyor environment" This reverts commit 8c48e93e5da0b435d01ada38e76ab343a187f30d. --- Tests/Documentation/RuleDocumentation.tests.ps1 | 14 +++++++------- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 2 +- Tests/Rules/AvoidUsingAlias.tests.ps1 | 2 +- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Documentation/RuleDocumentation.tests.ps1 b/Tests/Documentation/RuleDocumentation.tests.ps1 index 34c5571d1..ca41f4819 100644 --- a/Tests/Documentation/RuleDocumentation.tests.ps1 +++ b/Tests/Documentation/RuleDocumentation.tests.ps1 @@ -35,29 +35,29 @@ Describe "Validate rule documentation files" { $rulesReadmeDiff = Compare-Object -ReferenceObject $rules -DifferenceObject $readmeRules -SyncWindow 25 } - It "Every rule must have a rule documentation file" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every rule must have a rule documentation file" { $rulesDocsDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every rule documentation file must have a corresponding rule" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every rule documentation file must have a corresponding rule" { $rulesDocsDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every rule must have an entry in the rule documentation README.md file" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every rule must have an entry in the rule documentation README.md file" { $rulesReadmeDiff | Where-Object SideIndicator -eq "<=" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every entry in the rule documentation README.md file must correspond to a rule" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every entry in the rule documentation README.md file must correspond to a rule" { $rulesReadmeDiff | Where-Object SideIndicator -eq "=>" | Foreach-Object InputObject | Should -BeNullOrEmpty } - It "Every entry in the rule documentation README.md file must have a valid link to the documentation file" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Every entry in the rule documentation README.md file must have a valid link to the documentation file" { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link $filePath | Should -Exist } } - - It "Every rule name in the rule documentation README.md file must match the documentation file's basename" --Skip:($env:APPVEYOR -and $IsLinux) { + + It "Every rule name in the rule documentation README.md file must match the documentation file's basename" { foreach ($key in $readmeLinks.Keys) { $link = $readmeLinks[$key] $filePath = Join-Path $ruleDocDirectory $link diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index 54742e56c..c43cac665 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -533,7 +533,7 @@ Describe "Test -Fix Switch" { } Describe "Test -EnableExit Switch" { - It "Returns exit code equivalent to number of warnings" -Skip:($env:APPVEYOR -and $IsLinux) { + It "Returns exit code equivalent to number of warnings" { if ($IsCoreCLR) { pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' } diff --git a/Tests/Rules/AvoidUsingAlias.tests.ps1 b/Tests/Rules/AvoidUsingAlias.tests.ps1 index 359dffd3d..c92748977 100644 --- a/Tests/Rules/AvoidUsingAlias.tests.ps1 +++ b/Tests/Rules/AvoidUsingAlias.tests.ps1 @@ -95,7 +95,7 @@ Configuration MyDscConfiguration { $violations.Count | Should -Be 1 } - It "honors the whitelist in a case-insensitive manner" -Skip:($env:APPVEYOR -and $IsLinux) { + It "honors the whitelist in a case-insensitive manner" { $violations = Invoke-ScriptAnalyzer -ScriptDefinition "CD" -Settings $settings -IncludeRule $violationName $violations.Count | Should -Be 0 } diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index fd5b2b8ef..45ebef3d9 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -13,12 +13,12 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') } Describe "StandardDSCFunctionsInResource" { - Context "When there are violations" { - It "has 1 missing standard DSC functions violation" -Skip:($env:APPVEYOR -and $IsLinux) { + Context "When there are violations" { + It "has 1 missing standard DSC functions violation" { $violations.Count | Should -Be 1 } - It "has the correct description message" -Skip:($env:APPVEYOR -and $IsLinux) { + It "has the correct description message" { $violations[0].Message | Should -Match $violationMessage } } From ee7946706da820f6498a82b419952829464906eb Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 29 Dec 2018 21:05:39 +0000 Subject: [PATCH 27/45] set locale --- tools/appveyor.psm1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 46fc0736a..edb312c44 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -76,6 +76,9 @@ function Invoke-AppveyorTest { Copy-Item "${CheckoutPath}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "${CheckoutPath}\Tests\Engine","${CheckoutPath}\Tests\Rules","${CheckoutPath}\Tests\Documentation" + if ($IsLinuc -and $env:APPVEYOR) { + LANG = en_US.UTF-8 + } $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Resolve-Path $testResultsFile)) if ($testResults.FailedCount -gt 0) { From aded0eaab9df0f89cabf58059a32f8eeb1076132 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 20:29:34 +0000 Subject: [PATCH 28/45] empty From 91765b04f64ee7a864d94af18b7b8de63693feda Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 20:38:05 +0000 Subject: [PATCH 29/45] Revert "set locale" This reverts commit ee7946706da820f6498a82b419952829464906eb. --- tools/appveyor.psm1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index edb312c44..46fc0736a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -76,9 +76,6 @@ function Invoke-AppveyorTest { Copy-Item "${CheckoutPath}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "${CheckoutPath}\Tests\Engine","${CheckoutPath}\Tests\Rules","${CheckoutPath}\Tests\Documentation" - if ($IsLinuc -and $env:APPVEYOR) { - LANG = en_US.UTF-8 - } $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/${env:APPVEYOR_JOB_ID}", (Resolve-Path $testResultsFile)) if ($testResults.FailedCount -gt 0) { From 7db40c3c1ad32fbcacf6f3c9579d8c1895dc470a Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 20:54:51 +0000 Subject: [PATCH 30/45] simplify dotnet check --- tools/appveyor.psm1 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 46fc0736a..e4c2e0f4b 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,14 +33,7 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - if ($PSVersionTable.PSVersion.Major -gt 4) { - $requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion - } - else { - # WMF 4 image has old SDK that does not have --list-sdks parameter - $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion) - } - if (-not $requiredDotNetCoreSDKVersionPresent) { + if (-not ((dotnet --version).StartsWith($requiredDotNetCoreSDKVersion))) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From e57a0b27e8cc03dbf781e96c68d90be54bb7df40 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 21:46:59 +0000 Subject: [PATCH 31/45] output debug details and disable other images --- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 2 ++ appveyor.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index 45ebef3d9..9b6b37983 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -15,6 +15,7 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') Describe "StandardDSCFunctionsInResource" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { + $violations.RuleName $violations.Count | Should -Be 1 } @@ -34,6 +35,7 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') { Describe "StandardDSCFunctionsInClass" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { + $classViolations.RuleName $classViolations.Count | Should -Be 1 } diff --git a/appveyor.yml b/appveyor.yml index 07c891a40..e2d8968e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,13 +2,13 @@ environment: PSVersion: 5 BuildConfiguration: Release matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PowerShellEdition: PowerShellCore - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PowerShellEdition: WindowsPowerShell - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: WindowsPowerShell - PSVersion: 4 + # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + # PowerShellEdition: PowerShellCore + # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + # PowerShellEdition: WindowsPowerShell + # - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + # PowerShellEdition: WindowsPowerShell + # PSVersion: 4 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore From 84963f6c3418de384de4887feedda6a1172db204 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 21:54:48 +0000 Subject: [PATCH 32/45] output rule names --- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index 9b6b37983..d2e77c9ab 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -15,11 +15,16 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') Describe "StandardDSCFunctionsInResource" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { - $violations.RuleName + Write-Host $violations[0].RuleName + Write-Host $violations[1].RuleName + Write-Host $violations[2].RuleName $violations.Count | Should -Be 1 } It "has the correct description message" { + Write-Host $violations[0].RuleName + Write-Host $violations[1].RuleName + Write-Host $violations[2].RuleName $violations[0].Message | Should -Match $violationMessage } } From 884206a355185b6e33896bab7e6ea183269c429d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 21:55:55 +0000 Subject: [PATCH 33/45] output more --- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index d2e77c9ab..0ed9c17b1 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -22,15 +22,15 @@ Describe "StandardDSCFunctionsInResource" { } It "has the correct description message" { - Write-Host $violations[0].RuleName - Write-Host $violations[1].RuleName - Write-Host $violations[2].RuleName $violations[0].Message | Should -Match $violationMessage } } Context "When there are no violations" { It "returns no violations" { + Write-Host $noViolations[0].RuleName + Write-Host $noViolations[1].RuleName + Write-Host $noViolations[2].RuleName $noViolations.Count | Should -Be 0 } } @@ -40,7 +40,6 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') { Describe "StandardDSCFunctionsInClass" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { - $classViolations.RuleName $classViolations.Count | Should -Be 1 } From ae66e8187d3711feb114d106f1f578d6645ffbd4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 21:59:17 +0000 Subject: [PATCH 34/45] add more and downgrade sdk --- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 9 +++++++++ global.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index 0ed9c17b1..e6b3605c7 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -16,8 +16,17 @@ Describe "StandardDSCFunctionsInResource" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { Write-Host $violations[0].RuleName + Write-Host $violations[0].Message + Write-Host $violations[0].Line + Write-Host $violations[0].Column Write-Host $violations[1].RuleName + Write-Host $violations[1].Message + Write-Host $violations[1].Line + Write-Host $violations[1].Column Write-Host $violations[2].RuleName + Write-Host $violations[2].Message + Write-Host $violations[2].Line + Write-Host $violations[2].Column $violations.Count | Should -Be 1 } diff --git a/global.json b/global.json index d328f8082..c8f9e01ca 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.502" + "version": "2.1.500" } } From b9227b658ff1cfd2d20026f328b8029a7766b87c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:02:32 +0000 Subject: [PATCH 35/45] use 2.1.403 sdk --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index c8f9e01ca..fde1674a6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.500" + "version": "2.1.403" } } From a72cb1ab31c1b613025a3ffdefc3e587934d20a3 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:05:21 +0000 Subject: [PATCH 36/45] 2.1.401 sdk --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index fde1674a6..3520291b0 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.1.401" } } From 820630634f6696e69707f5eec7946f5bb369eeac Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:07:01 +0000 Subject: [PATCH 37/45] 2.1.400 sdk --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 3520291b0..dd12f3441 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.401" + "version": "2.1.400" } } From 81428c2e39dededc1667d69313614eaa8f2bdce1 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:07:54 +0000 Subject: [PATCH 38/45] Revert "simplify dotnet check" This reverts commit 7db40c3c1ad32fbcacf6f3c9579d8c1895dc470a. --- tools/appveyor.psm1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index e4c2e0f4b..46fc0736a 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,7 +33,14 @@ function Invoke-AppVeyorInstall { # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version - if (-not ((dotnet --version).StartsWith($requiredDotNetCoreSDKVersion))) { + if ($PSVersionTable.PSVersion.Major -gt 4) { + $requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion + } + else { + # WMF 4 image has old SDK that does not have --list-sdks parameter + $requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion) + } + if (-not $requiredDotNetCoreSDKVersionPresent) { Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion" $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol try { From 4fce77be25bac5c1380d5694acd95693ec3c357f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:08:09 +0000 Subject: [PATCH 39/45] 2.1.401 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index dd12f3441..3520291b0 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.400" + "version": "2.1.401" } } From 20fcc7a418aaa6f2b7d2e4aa11bd2b13fc032af6 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:10:06 +0000 Subject: [PATCH 40/45] 2.1.403 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 3520291b0..fde1674a6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.401" + "version": "2.1.403" } } From 2040651f1e17917753206068d94fa53bb77cec03 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:12:47 +0000 Subject: [PATCH 41/45] 2.1.502 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index fde1674a6..d328f8082 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.1.502" } } From 9794bfaa6749e9a81837fa6e81623dad9dba7124 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:41:06 +0000 Subject: [PATCH 42/45] fix resource string casing of AvoidUsingUsernameAndPassWordParams to AvoidUsingUsernameAndPasswordParams --- Rules/Strings.Designer.cs | 2 +- Rules/Strings.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs index ba1d61a4d..f63c3a3f5 100644 --- a/Rules/Strings.Designer.cs +++ b/Rules/Strings.Designer.cs @@ -602,7 +602,7 @@ internal static string AvoidUsernameAndPasswordParamsError { } /// - /// Looks up a localized string similar to AvoidUsingUserNameAndPassWordParams. + /// Looks up a localized string similar to AvoidUsingUserNameAndPasswordParams. /// internal static string AvoidUsernameAndPasswordParamsName { get { diff --git a/Rules/Strings.resx b/Rules/Strings.resx index d4ebf259c..089a70814 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -484,7 +484,7 @@ Function '{0}' has both Username and Password parameters. Either set the type of the Password parameter to SecureString or replace the Username and Password parameters with a Credential parameter of type PSCredential. If using a Credential parameter in PowerShell 4.0 or earlier, please define a credential transformation attribute after the PSCredential type attribute. - AvoidUsingUserNameAndPassWordParams + AvoidUsingUserNameAndPasswordParams Avoid Invoking Empty Members From ce8a531cc781a5481b912c178d5932576919d2c2 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:48:32 +0000 Subject: [PATCH 43/45] another resource string casing optimisation --- Rules/Strings.Designer.cs | 2 +- Rules/Strings.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs index f63c3a3f5..edb0a29f4 100644 --- a/Rules/Strings.Designer.cs +++ b/Rules/Strings.Designer.cs @@ -602,7 +602,7 @@ internal static string AvoidUsernameAndPasswordParamsError { } /// - /// Looks up a localized string similar to AvoidUsingUserNameAndPasswordParams. + /// Looks up a localized string similar to AvoidUsingUsernameAndPasswordParams. /// internal static string AvoidUsernameAndPasswordParamsName { get { diff --git a/Rules/Strings.resx b/Rules/Strings.resx index 089a70814..56cdb1794 100644 --- a/Rules/Strings.resx +++ b/Rules/Strings.resx @@ -484,7 +484,7 @@ Function '{0}' has both Username and Password parameters. Either set the type of the Password parameter to SecureString or replace the Username and Password parameters with a Credential parameter of type PSCredential. If using a Credential parameter in PowerShell 4.0 or earlier, please define a credential transformation attribute after the PSCredential type attribute. - AvoidUsingUserNameAndPasswordParams + AvoidUsingUsernameAndPasswordParams Avoid Invoking Empty Members From 941643271bf66d625708f8c5ed6984b914ec1df6 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 22:57:30 +0000 Subject: [PATCH 44/45] use OrdinalIgnoreCase to be really case insensitive --- Rules/UseStandardDSCFunctionsInResource.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rules/UseStandardDSCFunctionsInResource.cs b/Rules/UseStandardDSCFunctionsInResource.cs index b93147bf7..7022da2d4 100644 --- a/Rules/UseStandardDSCFunctionsInResource.cs +++ b/Rules/UseStandardDSCFunctionsInResource.cs @@ -35,7 +35,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName List expectedTargetResourceFunctionNames = new List(new string[] { "Get-TargetResource", "Set-TargetResource", "Test-TargetResource" }); // Retrieve a list of Asts where the function name contains TargetResource - IEnumerable functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.CurrentCultureIgnoreCase) != -1), true)); + IEnumerable functionDefinitionAsts = (ast.FindAll(dscAst => dscAst is FunctionDefinitionAst && ((dscAst as FunctionDefinitionAst).Name.IndexOf("targetResource", StringComparison.OrdinalIgnoreCase) != -1), true)); List targetResourceFunctionNamesInAst = new List(); foreach (FunctionDefinitionAst functionDefinitionAst in functionDefinitionAsts) @@ -46,7 +46,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName foreach (string expectedTargetResourceFunctionName in expectedTargetResourceFunctionNames) { // If the Ast does not contain the expected functions, provide a Rule violation message - if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.CurrentCultureIgnoreCase)) + if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.OrdinalIgnoreCase)) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInResourceError, expectedTargetResourceFunctionName), ast.Extent, GetName(), DiagnosticSeverity.Error, fileName); From f5c5b7dda1c1c113a91a417833564f9e4ee8e95a Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Thu, 3 Jan 2019 23:02:20 +0000 Subject: [PATCH 45/45] cleanup --- Tests/Rules/UseDSCResourceFunctions.tests.ps1 | 15 --------------- appveyor.yml | 14 +++++++------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index e6b3605c7..45ebef3d9 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -15,18 +15,6 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') Describe "StandardDSCFunctionsInResource" { Context "When there are violations" { It "has 1 missing standard DSC functions violation" { - Write-Host $violations[0].RuleName - Write-Host $violations[0].Message - Write-Host $violations[0].Line - Write-Host $violations[0].Column - Write-Host $violations[1].RuleName - Write-Host $violations[1].Message - Write-Host $violations[1].Line - Write-Host $violations[1].Column - Write-Host $violations[2].RuleName - Write-Host $violations[2].Message - Write-Host $violations[2].Line - Write-Host $violations[2].Column $violations.Count | Should -Be 1 } @@ -37,9 +25,6 @@ Describe "StandardDSCFunctionsInResource" { Context "When there are no violations" { It "returns no violations" { - Write-Host $noViolations[0].RuleName - Write-Host $noViolations[1].RuleName - Write-Host $noViolations[2].RuleName $noViolations.Count | Should -Be 0 } } diff --git a/appveyor.yml b/appveyor.yml index e2d8968e0..07c891a40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,13 +2,13 @@ environment: PSVersion: 5 BuildConfiguration: Release matrix: - # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - # PowerShellEdition: PowerShellCore - # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - # PowerShellEdition: WindowsPowerShell - # - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - # PowerShellEdition: WindowsPowerShell - # PSVersion: 4 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PowerShellEdition: PowerShellCore + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PowerShellEdition: WindowsPowerShell + - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + PowerShellEdition: WindowsPowerShell + PSVersion: 4 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore