From 7fd4fb9d539dc8561b443b828fe61379f671a589 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 10:40:42 +0000 Subject: [PATCH 01/33] test using pwsh --- appveyor.yml | 107 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 37 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9e5302718..b5b52e008 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,9 +3,9 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: Desktop BuildConfiguration: Release - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: Desktop - BuildConfiguration: PSv3Release +- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PowerShellEdition: PowerShellCore + BuildConfiguration: Release # clone directory clone_folder: c:\projects\psscriptanalyzer @@ -18,23 +18,37 @@ cache: # Install Pester install: - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\powershell\6.0.1\Modules\\." -ExcludeVersion - ps: | - $requiredPesterVersion = '4.3.1' - $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } - $pester - if ($null -eq $pester) - { - if ($null -eq (Get-Module -ListAvailable PowershellGet)) + if ($env:PowerShellEdition -eq 'Desktop') { + $requiredPesterVersion = '4.3.1' + $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } + $pester + if ($null -eq $pester) { - # WMF 4 image build - nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + if ($null -eq (Get-Module -ListAvailable PowershellGet)) + { + # WMF 4 image build + nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + } + else + { + # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) + Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser + } } - else + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + $requiredPesterVersion = '4.3.1' + $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } + $pester + if ($null -eq $pester) { - # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser } } + - ps: | # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content .\global.json -Raw | ConvertFrom-Json @@ -47,35 +61,54 @@ install: build_script: - ps: | - $PSVersionTable - Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose - Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose - Push-Location C:\projects\psscriptanalyzer - # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build - git clean -dfx - C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build - C:\projects\psscriptanalyzer\build.ps1 -BuildDocs - Pop-Location - -# branches to build -branches: - # whitelist - only: - - master - - development + if ($env:PowerShellEdition -eq 'Desktop') { + $PSVersionTable + Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose + Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose + Push-Location C:\projects\psscriptanalyzer + # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. + .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build + git clean -dfx + C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build + C:\projects\psscriptanalyzer\build.ps1 -BuildDocs + Pop-Location + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + $PSVersionTable + Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose + Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose + Push-Location C:\projects\psscriptanalyzer + # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. + .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build + C:\projects\psscriptanalyzer\build.ps1 -BuildDocs + Pop-Location + } # Run Pester tests and store the results test_script: - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | - copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force - $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" - $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) { - throw "$($testResults.FailedCount) tests failed." + if ($env:PowerShellEdition -eq 'Desktop') { + copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." + } + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.1\Modules\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." + } } # Upload the project along with TestResults as a zip archive From 4a32c11cb7fbb7e814712fc9ddd63997342e09b8 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 10:42:09 +0000 Subject: [PATCH 02/33] fix yaml syntax --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b5b52e008..3f619f722 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: Desktop BuildConfiguration: Release -- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: PowerShellCore BuildConfiguration: Release From f56bb8309df2b5e4b3caa52ddf9e4190d0236ae0 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 10:55:00 +0000 Subject: [PATCH 03/33] install platyps on pwsh --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3f619f722..73b180c34 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,6 @@ cache: # Install Pester install: - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion - - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\powershell\6.0.1\Modules\\." -ExcludeVersion - ps: | if ($env:PowerShellEdition -eq 'Desktop') { $requiredPesterVersion = '4.3.1' @@ -47,6 +46,7 @@ install: { Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser } + Install-Module -Name platyPS -Force } - ps: | From bd484a6c9a7dcc192d61390af591000d850ce01c Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 11:08:38 +0000 Subject: [PATCH 04/33] appveyor still uses pwsh 6.0.0 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 73b180c34..fc0263c7a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -101,7 +101,7 @@ test_script: } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.1\Modules\" -Recurse -Force + copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru From a8cea13cf7600e0d1e083cc1a952ecf6e2fe3d58 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 11:34:33 +0000 Subject: [PATCH 05/33] fix 1 test for pwsh. 1 remaining --- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index 414e24ff9..c35990c50 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -530,11 +530,23 @@ 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" { - $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + if ($null -eq $env:IsCoreCLR) { + $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + } + else { + $result = pwsh -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + } + "$result" | Should -BeLike $reportSummaryFor1Warning } It "does not print the report summary when not using -NoReportSummary switch" { - $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' + if ($null -eq $env:IsCoreCLR) { + $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' + } + else { + $result = pwsh -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' + } + "$result" | Should -Not -BeLike $reportSummaryFor1Warning } } From 8c6dafaace2a1a37347e5ef5278600bb47ea1622 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 11:42:23 +0000 Subject: [PATCH 06/33] make test pending that is failing on pwsh on Windows as well. --- Tests/Rules/UseToExportFieldsInManifest.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Rules/UseToExportFieldsInManifest.tests.ps1 b/Tests/Rules/UseToExportFieldsInManifest.tests.ps1 index e8556ef11..667a5f98f 100644 --- a/Tests/Rules/UseToExportFieldsInManifest.tests.ps1 +++ b/Tests/Rules/UseToExportFieldsInManifest.tests.ps1 @@ -83,7 +83,7 @@ Describe "UseManifestExportFields" { $results[0].Extent.Text | Should -Be "'*'" } - It "suggests corrections for AliasesToExport with wildcard" -pending:($IsLinux -or $IsMacOS) { + It "suggests corrections for AliasesToExport with wildcard" -pending:($IsCoreClr) { $violations = Run-PSScriptAnalyzerRule $testManifestBadAliasesWildcardPath $violationFilepath = Join-path $testManifestPath $testManifestBadAliasesWildcardPath Test-CorrectionExtent $violationFilepath $violations[0] 1 "'*'" "@('gbar', 'gfoo')" From d5af4a1530f8ab9339bbb322123e0709f044b560 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 11:49:32 +0000 Subject: [PATCH 07/33] re-fix test for pwsh --- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index c35990c50..6c12b486b 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -523,7 +523,12 @@ Describe "Test -Fix Switch" { Describe "Test -EnableExit Switch" { It "Returns exit code equivalent to number of warnings" { - powershell -Command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' + if ($null -eq $env:IsCoreCLR) { + powershell -command 'Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' + } + else { + pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' + } $LASTEXITCODE | Should -Be 1 } @@ -534,7 +539,7 @@ Describe "Test -EnableExit Switch" { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } else { - $result = pwsh -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } "$result" | Should -BeLike $reportSummaryFor1Warning @@ -544,7 +549,7 @@ Describe "Test -EnableExit Switch" { $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' } else { - $result = pwsh -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' + $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci' } "$result" | Should -Not -BeLike $reportSummaryFor1Warning From 4d43669d65ac2dc0de8dd9ab1afeaa1f8168a976 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 14:01:44 +0000 Subject: [PATCH 08/33] really fix test and simplify --- Tests/Engine/InvokeScriptAnalyzer.tests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 index 6c12b486b..fc149b95c 100644 --- a/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 +++ b/Tests/Engine/InvokeScriptAnalyzer.tests.ps1 @@ -523,11 +523,11 @@ Describe "Test -Fix Switch" { Describe "Test -EnableExit Switch" { It "Returns exit code equivalent to number of warnings" { - if ($null -eq $env:IsCoreCLR) { - powershell -command 'Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' + if ($IsCoreCLR) { + pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' } else { - pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' + powershell -command 'Invoke-ScriptAnalyzer -ScriptDefinition gci -EnableExit' } $LASTEXITCODE | Should -Be 1 } @@ -535,21 +535,21 @@ 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" { - if ($null -eq $env:IsCoreCLR) { - $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + if ($IsCoreCLR) { + $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } else { - $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' + $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci -ReportSummary' } "$result" | Should -BeLike $reportSummaryFor1Warning } It "does not print the report summary when not using -NoReportSummary switch" { - if ($null -eq $env:IsCoreCLR) { - $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' + if ($IsCoreCLR) { + $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci' } else { - $result = pwsh -command 'Import-Module PSScriptAnalyzer; Invoke-Scriptanalyzer -ScriptDefinition gci' + $result = powershell -command 'Invoke-Scriptanalyzer -ScriptDefinition gci' } "$result" | Should -Not -BeLike $reportSummaryFor1Warning From 49617f4d3bc7fa1a60c03acdebc8060f7aa8ec8f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 14:22:44 +0000 Subject: [PATCH 09/33] tweak and optimize appveyor.yml --- appveyor.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fc0263c7a..2668e8153 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,14 +15,12 @@ cache: - '%USERPROFILE%\.nuget\packages -> appveyor.yml' - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml' -# Install Pester +# Install Pester, PlatyPS and the required .Net Core SDK install: - - ps: nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion - ps: | if ($env:PowerShellEdition -eq 'Desktop') { $requiredPesterVersion = '4.3.1' $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } - $pester if ($null -eq $pester) { if ($null -eq (Get-Module -ListAvailable PowershellGet)) @@ -36,16 +34,11 @@ install: Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser } } + Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - $requiredPesterVersion = '4.3.1' - $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } - $pester - if ($null -eq $pester) - { - Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser - } + Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -RequiredVersion '4.3.1' Install-Module -Name platyPS -Force } @@ -66,11 +59,8 @@ build_script: Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose Push-Location C:\projects\psscriptanalyzer - # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build - git clean -dfx - C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build - C:\projects\psscriptanalyzer\build.ps1 -BuildDocs + .\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build + .\build.ps1 -BuildDocs Pop-Location } - pwsh: | @@ -79,9 +69,8 @@ build_script: Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose Push-Location C:\projects\psscriptanalyzer - # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build - C:\projects\psscriptanalyzer\build.ps1 -BuildDocs + .\build.ps1 -BuildDocs Pop-Location } @@ -90,7 +79,7 @@ test_script: - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | if ($env:PowerShellEdition -eq 'Desktop') { - copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru @@ -101,7 +90,7 @@ test_script: } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - copy-item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" $testResults = Invoke-Pester -Script $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru From 71b898dee4b50f80bdd97a5d991bfd3a6e5a7de1 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 15:14:28 +0000 Subject: [PATCH 10/33] extract appveyor steps into ps module to eliminate code duplication --- appveyor.yml | 83 ++++-------------------------------------- tools/appveyor.psm1 | 87 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 77 deletions(-) create mode 100644 tools/appveyor.psm1 diff --git a/appveyor.yml b/appveyor.yml index 2668e8153..360a96e77 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,90 +15,19 @@ cache: - '%USERPROFILE%\.nuget\packages -> appveyor.yml' - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml' -# Install Pester, PlatyPS and the required .Net Core SDK install: - - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { - $requiredPesterVersion = '4.3.1' - $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } - if ($null -eq $pester) - { - if ($null -eq (Get-Module -ListAvailable PowershellGet)) - { - # WMF 4 image build - nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion - } - else - { - # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) - Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser - } - } - Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' - } - - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -RequiredVersion '4.3.1' - Install-Module -Name platyPS -Force - } - - - ps: | - # the legacy WMF4 image only has the old preview SDKs of dotnet - $globalDotJson = Get-Content .\global.json -Raw | ConvertFrom-Json - $dotNetCoreSDKVersion = $globalDotJson.sdk.version - if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) - { - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 - .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion - } + - ps: if ($env:PowerShellEdition -eq 'Desktop') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } build_script: - - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { - $PSVersionTable - Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose - Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose - Push-Location C:\projects\psscriptanalyzer - .\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build - .\build.ps1 -BuildDocs - Pop-Location - } - - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - $PSVersionTable - Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose - Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose - Push-Location C:\projects\psscriptanalyzer - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build - .\build.ps1 -BuildDocs - Pop-Location - } + - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorBuild 'FullCLR' $env:BuildConfiguration 'C:\projects\psscriptanalyzer' } + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Invoke-AppveyorBuild 'NetStandard' $env:BuildConfiguration 'C:\projects\psscriptanalyzer' } # Run Pester tests and store the results test_script: - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; - - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force - $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" - $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) { - throw "$($testResults.FailedCount) tests failed." - } - } - - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force - $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" - $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) { - throw "$($testResults.FailedCount) tests failed." - } - } + - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} # Upload the project along with TestResults as a zip archive on_finish: diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 new file mode 100644 index 000000000..1bca2fa43 --- /dev/null +++ b/tools/appveyor.psm1 @@ -0,0 +1,87 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed. +function Invoke-AppVeyorInstall { + $requiredPesterVersion = '4.3.1' + $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } + if ($null -eq $pester) { + if ($null -eq (Get-Module -ListAvailable PowershellGet)) { + # WMF 4 image build + nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + } + else { + # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) + Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser + } + } + + Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' + + # 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))) { + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion + Remove-Item .\dotnet-install.ps1 + } +} + +# Implements the AppVeyor 'build_script' step +function Invoke-AppVeyorBuild { + Param( + [Parameter(Mandatory)] + [ValidateSet('FullCLR', 'NetStandard')] + $BuildType, + + [Parameter(Mandatory)] + [ValidateSet('Release', 'PSv3Release')] + $BuildConfiguration, + + [Parameter(Mandatory)] + [ValidateScript( {Test-Path $_})] + $CheckoutPath + ) + + $PSVersionTable + Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose + Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose + Push-Location $CheckoutPath + if ($BuildType -eq 'FullCLR') { + .\buildCoreClr.ps1 -Framework net451 -Configuration $BuildConfiguration -Build + } + elseif ($BuildType -eq 'NetStandard') { + .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build + } + .\build.ps1 -BuildDocs + Pop-Location +} + +# Implement AppVeyor 'Test_script' +function Invoke-AppVeyorTest { + Param( + [Parameter(Mandatory)] + [ValidateSet('WindowsPowerShell', 'PowerShellCore')] + $BuildType, + + [Parameter(Mandatory)] + [ValidateScript( {Test-Path $_})] + $CheckoutPath + ) + + $psScriptAnalyzerModuleOutput = (Join-Path $CheckoutPath 'out\PSScriptAnalyzer') + if ($BuildType -eq 'WindowsPowerShell') { + Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force + } + elseif ($BuildType -eq 'PowerShellCore') { + Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force + } + $testResultsFile = ".\TestResults.xml" + $testScripts = (Join-Path $CheckoutPath 'Test\Engine'),(Join-Path $CheckoutPath 'Test\Rules') + $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) { + throw "$($testResults.FailedCount) tests failed." + } +} \ No newline at end of file From 7fd574bf2b80abaaa7ba80d8fbe6728ad0688952 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 15:25:24 +0000 Subject: [PATCH 11/33] fix and simplify test script --- tools/appveyor.psm1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 1bca2fa43..1e75a0932 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -61,20 +61,16 @@ function Invoke-AppVeyorBuild { # Implement AppVeyor 'Test_script' function Invoke-AppVeyorTest { Param( - [Parameter(Mandatory)] - [ValidateSet('WindowsPowerShell', 'PowerShellCore')] - $BuildType, - [Parameter(Mandatory)] [ValidateScript( {Test-Path $_})] $CheckoutPath ) $psScriptAnalyzerModuleOutput = (Join-Path $CheckoutPath 'out\PSScriptAnalyzer') - if ($BuildType -eq 'WindowsPowerShell') { + if ($IsCoreCLR) { Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force } - elseif ($BuildType -eq 'PowerShellCore') { + else { Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force } $testResultsFile = ".\TestResults.xml" From 92de2cae92af29d6e95dac7f9936e617c43ea68d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 15:33:45 +0000 Subject: [PATCH 12/33] fix path problem and put appveyor finish into module as well --- appveyor.yml | 14 +++----------- tools/appveyor.psm1 | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 360a96e77..d74fe3a56 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: BuildConfiguration: Release # clone directory -clone_folder: c:\projects\psscriptanalyzer +clone_folder: C:\projects\psscriptanalyzer # cache Nuget packages and dotnet CLI cache cache: @@ -29,14 +29,6 @@ test_script: - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} -# Upload the project along with TestResults as a zip archive +# Upload the project along with test results as a zip archive on_finish: - - ps: | - $stagingDirectory = (Resolve-Path ..).Path - $zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip" - Add-Type -assemblyname System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile) - @( - # You can add other artifacts here - (ls $zipFile) - ) | % { Push-AppveyorArtifact $_.FullName } + - ps: Invoke-AppveyorFinish diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 1e75a0932..95cd9877d 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -8,7 +8,7 @@ function Invoke-AppVeyorInstall { if ($null -eq $pester) { if ($null -eq (Get-Module -ListAvailable PowershellGet)) { # WMF 4 image build - nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion } else { # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) @@ -73,11 +73,23 @@ function Invoke-AppVeyorTest { else { Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force } - $testResultsFile = ".\TestResults.xml" - $testScripts = (Join-Path $CheckoutPath 'Test\Engine'),(Join-Path $CheckoutPath 'Test\Rules') + $testResultsFile = '.\TestResults.xml' + $testScripts = (Join-Path $CheckoutPath 'Tests\Engine'),(Join-Path $CheckoutPath 'Tests\Rules') $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) { throw "$($testResults.FailedCount) tests failed." } +} + +# Implements AppVeyor 'on_finish' step +function Invoke-AppveyorFinish { + $stagingDirectory = (Resolve-Path ..).Path + $zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip" + Add-Type -AssemblyName 'System.IO.Compression.FileSystem' + [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile) + @( + # You can add other artifacts here + (Get-ChildItem $zipFile) + ) | ForEach-Object { Push-AppveyorArtifact $_.FullName } } \ No newline at end of file From 796189df5e22dde77b6b38dbae64aac40768534f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 15:49:13 +0000 Subject: [PATCH 13/33] pwsh sessions are not being persisted on appveyor. Fix module deployment as well --- appveyor.yml | 33 +++++++++++++++++++++++++-------- tools/appveyor.psm1 | 4 ++-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d74fe3a56..d69129fe8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,14 @@ environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PowerShellEdition: Desktop + PowerShellEdition: PowerShellCore BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PowerShellEdition: PowerShellCore + PowerShellEdition: Desktop BuildConfiguration: Release + - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + PowerShellEdition: Desktop + BuildConfiguration: PSv3Release # clone directory clone_folder: C:\projects\psscriptanalyzer @@ -20,15 +23,29 @@ install: - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } build_script: - - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorBuild 'FullCLR' $env:BuildConfiguration 'C:\projects\psscriptanalyzer' } - - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Invoke-AppveyorBuild 'NetStandard' $env:BuildConfiguration 'C:\projects\psscriptanalyzer' } + - ps: | + if ($env:PowerShellEdition -eq 'Desktop') { + Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps + Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' + } # Run Pester tests and store the results test_script: - - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; - - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} - - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Invoke-AppveyorTest 'C:\projects\psscriptanalyzer'} + - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; + - ps: | + if ($env:PowerShellEdition -eq 'Desktop') { + Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps + Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + } # Upload the project along with test results as a zip archive on_finish: - - ps: Invoke-AppveyorFinish + - ps: Invoke-AppveyorFinish diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 95cd9877d..8aab8de3e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -68,10 +68,10 @@ function Invoke-AppVeyorTest { $psScriptAnalyzerModuleOutput = (Join-Path $CheckoutPath 'out\PSScriptAnalyzer') if ($IsCoreCLR) { - Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force + Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force } else { - Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force + Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force } $testResultsFile = '.\TestResults.xml' $testScripts = (Join-Path $CheckoutPath 'Tests\Engine'),(Join-Path $CheckoutPath 'Tests\Rules') From d14edfeeb563ebd90d5642e1c6ac377442558bbe Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 15:50:13 +0000 Subject: [PATCH 14/33] remove wmf4 image temporarily to run it on the fork again --- appveyor.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d69129fe8..c9af7f023 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,6 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: Desktop BuildConfiguration: Release - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: Desktop - BuildConfiguration: PSv3Release # clone directory clone_folder: C:\projects\psscriptanalyzer From 20025cb693f4a438ba84f30cbfe5b46930046539 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:04:38 +0000 Subject: [PATCH 15/33] revert test script to non-module version because some tests failed --- appveyor.yml | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c9af7f023..faebb496e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,6 @@ environment: PowerShellEdition: Desktop BuildConfiguration: Release -# clone directory clone_folder: C:\projects\psscriptanalyzer # cache Nuget packages and dotnet CLI cache @@ -30,19 +29,32 @@ build_script: Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' } -# Run Pester tests and store the results test_script: - - SET PATH=c:\Program Files\WindowsPowerShell\Modules\;%PATH%; - - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { - Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; + - ps: | + if ($env:PowerShellEdition -eq 'Desktop') { + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." } - - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps - Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + } + - pwsh: | + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." } + } # Upload the project along with test results as a zip archive on_finish: - - ps: Invoke-AppveyorFinish + - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorFinish } + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorFinish } From 5f62577d857c290ae9c9846801c7a0e46693b658 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:07:02 +0000 Subject: [PATCH 16/33] try fix yaml syntax --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index faebb496e..8673f47e8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,7 +30,7 @@ build_script: } test_script: - - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; + - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | if ($env:PowerShellEdition -eq 'Desktop') { Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force From f880cf9833362955c1304fad3bcd833b1ffb58f7 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:18:36 +0000 Subject: [PATCH 17/33] use consistent space and try $ErrorActionPreference = 'Stop' in appveyor module --- appveyor.yml | 9 ++++----- tools/appveyor.psm1 | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8673f47e8..ef3419cc2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,8 +30,8 @@ build_script: } test_script: - - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - - ps: | + - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; + - ps: | if ($env:PowerShellEdition -eq 'Desktop') { Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force $testResultsFile = ".\TestResults.xml" @@ -42,7 +42,7 @@ test_script: throw "$($testResults.FailedCount) tests failed." } } - - pwsh: | + - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force $testResultsFile = ".\TestResults.xml" @@ -56,5 +56,4 @@ test_script: # Upload the project along with test results as a zip archive on_finish: - - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorFinish } - - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorFinish } + - ps: Invoke-AppveyorFinish diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 8aab8de3e..f5276cd30 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -1,6 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +$ErrorActionPreference = 'Stop' + # Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed. function Invoke-AppVeyorInstall { $requiredPesterVersion = '4.3.1' From db72dcbc485c58daa46084c488892cc372602786 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:26:06 +0000 Subject: [PATCH 18/33] fix appveyorfinish for pwsh and give test-appveyor function a last try --- appveyor.yml | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ef3419cc2..4f1d15579 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,8 @@ cache: - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml' install: - - ps: if ($env:PowerShellEdition -eq 'Desktop') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } + - ps: Import-Module .\tools\Appveyor.psm1 + - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorInstall } - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } build_script: @@ -31,28 +32,15 @@ build_script: test_script: - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force - $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" - $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) { - throw "$($testResults.FailedCount) tests failed." + - ps: | + if ($env:PowerShellEdition -eq 'Desktop') { + Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' } - } - pwsh: | - if ($env:PowerShellEdition -eq 'PowerShellCore') { - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$Env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force - $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" - $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) { - throw "$($testResults.FailedCount) tests failed." + if ($env:PowerShellEdition -eq 'PowerShellCore') { + Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps + Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' } - } # Upload the project along with test results as a zip archive on_finish: From d285e457e5d8973aeba03e02acb2ec5d1d132554 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:41:00 +0000 Subject: [PATCH 19/33] take out invoke-appveyortest method since it does not work in the appveyor environment --- appveyor.yml | 22 +++++++++++++++++++--- tools/appveyor.psm1 | 24 ------------------------ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4f1d15579..f293150e5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,16 +30,32 @@ build_script: Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' } +# Test scripts are not in a module function because the tests behave differently for unknown reasons in AppVeyor test_script: - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | if ($env:PowerShellEdition -eq 'Desktop') { - Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." + } } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps - Invoke-AppveyorTest -CheckoutPath 'C:\projects\psscriptanalyzer' + $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 + Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force + $testResultsFile = ".\TestResults.xml" + $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $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) { + throw "$($testResults.FailedCount) tests failed." + } } # Upload the project along with test results as a zip archive diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index f5276cd30..e9f38994e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -60,30 +60,6 @@ function Invoke-AppVeyorBuild { Pop-Location } -# Implement AppVeyor 'Test_script' -function Invoke-AppVeyorTest { - Param( - [Parameter(Mandatory)] - [ValidateScript( {Test-Path $_})] - $CheckoutPath - ) - - $psScriptAnalyzerModuleOutput = (Join-Path $CheckoutPath 'out\PSScriptAnalyzer') - if ($IsCoreCLR) { - Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\powershell\6.0.0\Modules\" -Recurse -Force - } - else { - Copy-Item $psScriptAnalyzerModuleOutput "$env:ProgramFiles\WindowsPowerShell\Modules\" -Recurse -Force - } - $testResultsFile = '.\TestResults.xml' - $testScripts = (Join-Path $CheckoutPath 'Tests\Engine'),(Join-Path $CheckoutPath 'Tests\Rules') - $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) { - throw "$($testResults.FailedCount) tests failed." - } -} - # Implements AppVeyor 'on_finish' step function Invoke-AppveyorFinish { $stagingDirectory = (Resolve-Path ..).Path From 557091f4835ba4a786d5b52a454e5048a8c94545 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 16:53:32 +0000 Subject: [PATCH 20/33] add wmf4 image as it is ready for PW now. --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index f293150e5..a3437e717 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,9 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: Desktop BuildConfiguration: Release + - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + PowerShellEdition: Desktop + BuildConfiguration: PSv3Release clone_folder: C:\projects\psscriptanalyzer From ef57ef3e816b297dbc75b8fb20f0f4a3d37ba0b4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 17:08:54 +0000 Subject: [PATCH 21/33] install platyps in a wmf4 friendly way --- tools/appveyor.psm1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index e9f38994e..45f0bdda6 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -18,7 +18,13 @@ function Invoke-AppVeyorInstall { } } - Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' + if ($null -eq (Get-Module -ListAvailable PowershellGet)) { + # WMF 4 image build + nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + } + else { + Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' + } # the legacy WMF4 image only has the old preview SDKs of dotnet $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json From d5c210491a5ce423edc984505f98daa5a5444d20 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 17:25:05 +0000 Subject: [PATCH 22/33] let's try if we can remove the hard coded checkout path (fingers crossed this works in WMF as well) --- appveyor.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a3437e717..f7f3bbc09 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,8 +10,6 @@ environment: PowerShellEdition: Desktop BuildConfiguration: PSv3Release -clone_folder: C:\projects\psscriptanalyzer - # cache Nuget packages and dotnet CLI cache cache: - '%USERPROFILE%\.nuget\packages -> appveyor.yml' @@ -25,12 +23,12 @@ install: build_script: - ps: | if ($env:PowerShellEdition -eq 'Desktop') { - Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' + Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps - Invoke-AppveyorBuild -CheckoutPath 'C:\projects\psscriptanalyzer' -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' + Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' } # Test scripts are not in a module function because the tests behave differently for unknown reasons in AppVeyor @@ -39,9 +37,9 @@ test_script: - ps: | if ($env:PowerShellEdition -eq 'Desktop') { $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force + Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" $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) { @@ -51,9 +49,9 @@ test_script: - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 - Copy-Item "C:\projects\psscriptanalyzer\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force + Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" - $testScripts = "C:\projects\psscriptanalyzer\Tests\Engine","C:\projects\psscriptanalyzer\Tests\Rules" + $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" $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 71facf8084ead95790fa0660931439a3ee366d8d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 17:33:53 +0000 Subject: [PATCH 23/33] let's try if we can rename the PowerShellEdition to something more meaningful (again fingers crossed for the WMF 4 build) --- appveyor.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f7f3bbc09..8349b6140 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,10 +4,10 @@ environment: PowerShellEdition: PowerShellCore BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - PowerShellEdition: Desktop + PowerShellEdition: WindowsPowerShell BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: Desktop + PowerShellEdition: WindowsPowerShell BuildConfiguration: PSv3Release # cache Nuget packages and dotnet CLI cache @@ -17,12 +17,12 @@ cache: install: - ps: Import-Module .\tools\Appveyor.psm1 - - ps: if ($env:PowerShellEdition -eq 'Desktop') { Invoke-AppveyorInstall } + - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } build_script: - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { + if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR' } - pwsh: | @@ -35,7 +35,7 @@ build_script: test_script: - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | - if ($env:PowerShellEdition -eq 'Desktop') { + if ($env:PowerShellEdition -eq 'WindowsPowerShell') { $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" From 34553e07acbb1e6b436cf394a29ae01e545c6623 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 17:45:29 +0000 Subject: [PATCH 24/33] Set DOTNET_SKIP_FIRST_TIME_EXPERIENCE to 1 to speed-up WMF4 builds, which have to install the .net sdk from scratch --- tools/appveyor.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 45f0bdda6..bbac9a0a2 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -56,6 +56,7 @@ function Invoke-AppVeyorBuild { Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose Push-Location $CheckoutPath + [Environment]::SetEnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", 1) # avoid unneccessary initialization in CI if ($BuildType -eq 'FullCLR') { .\buildCoreClr.ps1 -Framework net451 -Configuration $BuildConfiguration -Build } From 53493c98dace0647d2ef9e15a1d76899b0d73eb4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 17 Mar 2018 17:56:43 +0000 Subject: [PATCH 25/33] make indentation consistent after rename --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8349b6140..cd55e80c3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,8 +17,8 @@ cache: install: - ps: Import-Module .\tools\Appveyor.psm1 - - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } - - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } + - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } build_script: - ps: | From b535971594c1adb62c9f1bf800e16636c15650b5 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 18 Mar 2018 09:42:50 +0000 Subject: [PATCH 26/33] remove setting PATH for psmodulepath in yaml (not needed for VS 2017 image, let's hope it works for WMF 4 as well) --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index cd55e80c3..e40057046 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,6 @@ build_script: # Test scripts are not in a module function because the tests behave differently for unknown reasons in AppVeyor test_script: - - SET PATH=C:\Program Files\WindowsPowerShell\Modules\;%PATH%; - ps: | if ($env:PowerShellEdition -eq 'WindowsPowerShell') { $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 From 403bb6083045add4d8150642cc05e0acfeafa521 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 06:57:25 +0000 Subject: [PATCH 27/33] try ubuntu image --- appveyor.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e40057046..6cd3bae64 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,12 +3,9 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: PowerShellCore BuildConfiguration: Release - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: WindowsPowerShell BuildConfiguration: Release - - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 - PowerShellEdition: WindowsPowerShell - BuildConfiguration: PSv3Release # cache Nuget packages and dotnet CLI cache cache: From 8bbe0ed3b43476508497efeca77753722dd63fcc Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 06:58:24 +0000 Subject: [PATCH 28/33] fix ps edition --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 6cd3bae64..77ec346bd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,7 @@ environment: PowerShellEdition: PowerShellCore BuildConfiguration: Release - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu - PowerShellEdition: WindowsPowerShell + PowerShellEdition: PowerShellCore BuildConfiguration: Release # cache Nuget packages and dotnet CLI cache From 3cd76679d91d8adbbf9174122fc458cf3d787cf8 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 07:00:11 +0000 Subject: [PATCH 29/33] fix test for linux --- appveyor.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 77ec346bd..d206bdb52 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -44,7 +44,13 @@ test_script: } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 + if ($IsLinux) { + $modulePath = $env:PSModulePath.Split(':') | Where-Object { Test-Path $_} | Select-Object -First 1 + } + else + { + $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 + } Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" From a3f0405116e855b9f436b455f77d2bade8dca544 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 07:09:47 +0000 Subject: [PATCH 30/33] add debugging code --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d206bdb52..2a82edf33 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ cache: - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml' install: - - ps: Import-Module .\tools\Appveyor.psm1 + - ps: Get-Location; Write-Host "loc:'${env:APPVEYOR_BUILD_FOLDER}'"; Import-Module .\tools\Appveyor.psm1 - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } From 160f3a29e1f3370b74c8300585cfddd11ed3f535 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 07:17:13 +0000 Subject: [PATCH 31/33] fix case sensitivity problems --- appveyor.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2a82edf33..25ec193ed 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,9 +13,8 @@ cache: - '%LocalAppData%\Microsoft\dotnet -> appveyor.yml' install: - - ps: Get-Location; Write-Host "loc:'${env:APPVEYOR_BUILD_FOLDER}'"; Import-Module .\tools\Appveyor.psm1 - - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Invoke-AppveyorInstall } - - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\Appveyor.psm1; Invoke-AppveyorInstall } + - ps: if ($env:PowerShellEdition -eq 'WindowsPowerShell') { Import-Module .\tools\appveyor.psm1; Invoke-AppveyorInstall } + - pwsh: if ($env:PowerShellEdition -eq 'PowerShellCore') { Import-Module .\tools\appveyor.psm1; Invoke-AppveyorInstall } build_script: - ps: | @@ -24,7 +23,7 @@ build_script: } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - Import-Module .\tools\Appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps + Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard' } @@ -44,13 +43,7 @@ test_script: } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { - if ($IsLinux) { - $modulePath = $env:PSModulePath.Split(':') | Where-Object { Test-Path $_} | Select-Object -First 1 - } - else - { - $modulePath = $env:PSModulePath.Split(';') | Where-Object { Test-Path $_} | Select-Object -First 1 - } + $modulePath = $env:PSModulePath.Split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path $_} | Select-Object -First 1 Copy-Item "${env:APPVEYOR_BUILD_FOLDER}\out\PSScriptAnalyzer" "$modulePath\" -Recurse -Force $testResultsFile = ".\TestResults.xml" $testScripts = "${env:APPVEYOR_BUILD_FOLDER}\Tests\Engine","${env:APPVEYOR_BUILD_FOLDER}\Tests\Rules" @@ -63,4 +56,4 @@ test_script: # Upload the project along with test results as a zip archive on_finish: - - ps: Invoke-AppveyorFinish + - ps: Import-Module .\tools\appveyor.psm1; Invoke-AppveyorFinish From a0df25c3c910f2d0a9eee23280fd99ec819c807f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 19 Mar 2018 08:15:54 +0000 Subject: [PATCH 32/33] re-add other images for PR --- appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 25ec193ed..2fac5661b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,12 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 PowerShellEdition: PowerShellCore BuildConfiguration: Release + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + PowerShellEdition: WindowsPowerShell + BuildConfiguration: Release + - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4 + PowerShellEdition: WindowsPowerShell + BuildConfiguration: PSv3Release - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu PowerShellEdition: PowerShellCore BuildConfiguration: Release From e815a31d6a579bf4269c27364d8d0737c167a0d5 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 23 Mar 2018 08:48:13 +0000 Subject: [PATCH 33/33] git mv rules\UseSupportsShouldProcess.cs Rules\UseSupportsShouldProcess.cs --- {rules => Rules}/UseSupportsShouldProcess.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {rules => Rules}/UseSupportsShouldProcess.cs (100%) diff --git a/rules/UseSupportsShouldProcess.cs b/Rules/UseSupportsShouldProcess.cs similarity index 100% rename from rules/UseSupportsShouldProcess.cs rename to Rules/UseSupportsShouldProcess.cs