From f60bf883b5ba4971874627ecfe2a5f890416f37b Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 12:32:33 -0700 Subject: [PATCH 1/8] Add additional output to assist with debugging if there is a problem --- tools/appveyor.psm1 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 65dd71304..670274172 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -95,12 +95,19 @@ function Invoke-AppveyorTest { 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((Join-Path $pwd 'out'), $zipFile) - @( - # add test results as an artifact - (Get-ChildItem TestResults.xml) - # You can add other artifacts here - (Get-ChildItem $zipFile) - ) | ForEach-Object { Push-AppveyorArtifact $_.FullName } + $targetDir = Join-Path $pwd out + if ( ! ( test-path $targetDir ) ) { + # provide some additional data to help with debugging + Get-ChildItem $PWD | Write-Verbose -Verbose + } + else { + Add-Type -AssemblyName 'System.IO.Compression.FileSystem' + [System.IO.Compression.ZipFile]::CreateFromDirectory($targetDir, $zipFile) + @( + # add test results as an artifact + (Get-ChildItem TestResults.xml) + # You can add other artifacts here + (Get-ChildItem $zipFile) + ) | ForEach-Object { Push-AppveyorArtifact $_.FullName } + } } From c1db4c2e1a356f3513bad5b7a4251fe15a771df1 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 12:50:55 -0700 Subject: [PATCH 2/8] Add more debugging to build.psm1 --- build.psm1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index b7bffba05..d17c21bb0 100644 --- a/build.psm1 +++ b/build.psm1 @@ -250,7 +250,10 @@ function Start-ScriptAnalyzerBuild $script:DotnetExe = Get-DotnetExe } $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$config" 2>&1 - if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } + if ( $LASTEXITCODE -ne 0 ) { + $buildOutput | Write-Verbose -Verbose + throw "$buildOutput" + } } catch { Write-Warning $_ @@ -640,9 +643,13 @@ function Get-DotnetExe $dotnetHuntPath = "$HOME/.dotnet/dotnet" Write-Verbose -Verbose "checking non-Windows $dotnetHuntPath" if ( test-path $dotnetHuntPath ) { + Write-Verbose -Verbose "$dotnetHuntPath found" $script:DotnetExe = $dotnetHuntPath return $dotnetHuntPath } + else { + Write-Verbose -Verbose "$dotnetHuntPath not found" + } } Write-Warning "Could not find dotnet executable" From f7dc29ad7ecda1855b9aaa49e6ef3e0ff45c3ee0 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 14:27:49 -0700 Subject: [PATCH 3/8] additional debug output v3 --- build.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index d17c21bb0..020f067d5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -159,7 +159,7 @@ function Start-ScriptAnalyzerBuild # don't allow the build to be started unless we have the proper Cli version # this will not actually install dotnet if it's already present, but it will # install the proper version - Install-Dotnet + Install-Dotnet -Verbose if ( -not (Test-SuitableDotnet) ) { $requiredVersion = Get-GlobalJsonSdkVersion $foundVersion = Get-InstalledCLIVersion @@ -246,6 +246,7 @@ function Start-ScriptAnalyzerBuild try { Push-Location $projectRoot/Rules Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" + Write-Verbose -verbose "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" if ( -not $script:DotnetExe ) { $script:DotnetExe = Get-DotnetExe } @@ -403,6 +404,7 @@ function Install-Dotnet } } catch { + Write-Warning "Failure build.psm1 line 407" throw $_ } finally { @@ -546,6 +548,7 @@ function Get-InstalledCLIVersion { } } catch { + Write-Warning "${script:DotnetExe} --list-sdks" Write-Verbose -Verbose "$_" $installedVersions = & $script:DotnetExe --version 2>$null } @@ -610,7 +613,9 @@ function Receive-DotnetInstallScript } $uri = "https://dot.net/v1/${installScriptName}" + Write-Verbose -Verbose "downloading $urt" $installScript = Receive-File -Uri $uri + Write-Verbose -Verbose "InstallScript is $installScript" return $installScript.FullName } From 7bd18a3bda3d4ac8509d1ca1a273e8bb5bb540fe Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 15:11:01 -0700 Subject: [PATCH 4/8] v4 debugging --- appveyor.yml | 2 ++ build.psm1 | 4 ++++ tools/appveyor.psm1 | 10 ++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d3f02b1be..8bb77f9f1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,7 +34,9 @@ build_script: - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER + Write-Verbose -Verbose "calling build.ps1" ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6 + Write-Verbose -Verbose "calling PSCompatibility/build.ps1" ./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netstandard2.0' } diff --git a/build.psm1 b/build.psm1 index 020f067d5..90c1da67c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -156,6 +156,7 @@ function Start-ScriptAnalyzerBuild ) BEGIN { + Write-Verbose -Verbose "Start-ScriptAnalyzerBuild BEGIN" # don't allow the build to be started unless we have the proper Cli version # this will not actually install dotnet if it's already present, but it will # install the proper version @@ -168,6 +169,7 @@ function Start-ScriptAnalyzerBuild } END { + Write-Verbose -Verbose "Start-ScriptAnalyzerBuild END" # Build docs either when -Documentation switch is being specified or the first time in a clean repo $documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml') if ( $Documentation -or -not $documentationFileExists ) @@ -394,6 +396,7 @@ function Install-Dotnet Push-Location $PSScriptRoot $installScriptPath = Receive-DotnetInstallScript $installScriptName = [System.IO.Path]::GetFileName($installScriptPath) + Write-Verbose -Verbose "installscript is $installScriptPath" If ( $PSCmdlet.ShouldProcess("$installScriptName for $version")) { & "${installScriptPath}" -c release -version $version } @@ -401,6 +404,7 @@ function Install-Dotnet # set up the executable variable if ( -not $script:DotnetExe ) { $script:DotnetExe = Get-DotnetExe + Write-Verbose -Verbose "Setting DotnetExe variable to ${script:DotnetExe}" } } catch { diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 670274172..0fe4c1de0 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -33,9 +33,15 @@ function Invoke-AppVeyorInstall { # the build script sorts out the problems of WMF4 and earlier versions of dotnet CLI Write-Verbose -Verbose "Installing required .Net CORE SDK" - Write-Verbose "& $buildScriptDir/build.ps1 -bootstrap" $buildScriptDir = (Resolve-Path "$PSScriptRoot/..").Path - & "$buildScriptDir/build.ps1" -bootstrap + Write-Verbose -Verbose "& $buildScriptDir/build.ps1 -bootstrap" + try { + & "$buildScriptDir/build.ps1" -bootstrap + Write-Verbose -Verbose "exiting Invoke-AppVeyorInstall" + } + catch { + Write-Warning "error in invocation of build.ps1 from Invoke-AppVeyorInstall" + } } # Implements AppVeyor 'test_script' step From 4b5eb3a89f83d8ba3f4b26343b54f8268b9a4b75 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 15:35:50 -0700 Subject: [PATCH 5/8] v5 debugging --- tools/appveyor.psm1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 0fe4c1de0..ac4aeeb08 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -37,7 +37,8 @@ function Invoke-AppVeyorInstall { Write-Verbose -Verbose "& $buildScriptDir/build.ps1 -bootstrap" try { & "$buildScriptDir/build.ps1" -bootstrap - Write-Verbose -Verbose "exiting Invoke-AppVeyorInstall" + Write-Verbose -Verbose "exiting Invoke-AppVeyorInstall ($LASTEXITCODE)" + Write-Verbose -Verbose "bootstrap complete: $(get-date)" } catch { Write-Warning "error in invocation of build.ps1 from Invoke-AppVeyorInstall" From 296295886c398f1b863afd99eb1bfc31e80a63d1 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 15:52:22 -0700 Subject: [PATCH 6/8] v6 debugging --- appveyor.yml | 14 +++++++------- tools/appveyor.psm1 | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8bb77f9f1..81bcb51a4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,15 +3,15 @@ environment: BuildConfiguration: Release DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # For faster CI builds 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: Ubuntu PowerShellEdition: PowerShellCore +# - 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 # cache Nuget packages and dotnet CLI cache cache: diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index ac4aeeb08..b0637b8f2 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -38,6 +38,7 @@ function Invoke-AppVeyorInstall { try { & "$buildScriptDir/build.ps1" -bootstrap Write-Verbose -Verbose "exiting Invoke-AppVeyorInstall ($LASTEXITCODE)" + $GLOBAL:LASTEXITCODE = $LASTEXITCODE = 0 Write-Verbose -Verbose "bootstrap complete: $(get-date)" } catch { From 7f2989397ab306aefeb57fe67b1e3780914e6b79 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 16:10:19 -0700 Subject: [PATCH 7/8] v7 debugging --- PSCompatibilityCollector/build.ps1 | 8 +++++++- build.psm1 | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PSCompatibilityCollector/build.ps1 b/PSCompatibilityCollector/build.ps1 index d015d4453..fd70aa716 100644 --- a/PSCompatibilityCollector/build.ps1 +++ b/PSCompatibilityCollector/build.ps1 @@ -57,7 +57,13 @@ function Invoke-CrossCompatibilityModuleBuild Push-Location $script:BinModSrcDir try { - dotnet publish -f $Framework -c $Configuration + if ( test-path "$HOME/.dotnet/dotnet" ) { + $dotnet = "$HOME/.dotnet/dotnet" + } + else { + $dotnet = "dotnet" + } + & $dotnet publish -f $Framework -c $Configuration } finally { diff --git a/build.psm1 b/build.psm1 index 90c1da67c..c1cba780b 100644 --- a/build.psm1 +++ b/build.psm1 @@ -267,6 +267,7 @@ function Start-ScriptAnalyzerBuild Pop-Location } + Write-Verbose -Verbose "Publish-File to ${script:destinationDir}" Publish-File $itemsToCopyCommon $script:destinationDir $itemsToCopyBinaries = @( From 02d419f5e9daf89d0ef55fa27f07aeb15de40099 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 19 Jul 2019 16:36:13 -0700 Subject: [PATCH 8/8] v8 debug --- Tests/Engine/CustomizedRule.tests.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/Engine/CustomizedRule.tests.ps1 b/Tests/Engine/CustomizedRule.tests.ps1 index 301586667..9425e2fdc 100644 --- a/Tests/Engine/CustomizedRule.tests.ps1 +++ b/Tests/Engine/CustomizedRule.tests.ps1 @@ -97,10 +97,10 @@ Describe "Test importing correct customized rules" { It "will show the custom rules when given a glob" { # needs fixing for Linux $expectedNumRules = 4 - if ($IsLinux) - { - $expectedNumRules = 3 - } + #if ($IsLinux) + #{ + # $expectedNumRules = 3 + #} $customizedRulePath = Get-ScriptAnalyzerRule -CustomizedRulePath $directory\samplerule\samplerule* | Where-Object {$_.RuleName -match $measure} $customizedRulePath.Count | Should -Be $expectedNumRules } @@ -113,10 +113,10 @@ Describe "Test importing correct customized rules" { It "will show the custom rules when given glob with recurse switch" { # needs fixing for Linux $expectedNumRules = 5 - if ($IsLinux) - { - $expectedNumRules = 4 - } + #if ($IsLinux) + #{ + # $expectedNumRules = 4 + #} $customizedRulePath = Get-ScriptAnalyzerRule -RecurseCustomRulePath -CustomizedRulePath $directory\samplerule\samplerule* | Where-Object {$_.RuleName -eq $measure} $customizedRulePath.Count | Should -Be $expectedNumRules }