Reduce the console output of build (#54)

1. Reduce the console output of build
2. move to use powershell core 6.0.0.14
3. one minor fix in pester tests.

* Update the path of unittest results and build log. suppress the warning message.

* limitoutput of choco installation.

* fix of quotes

* remove redundant log

* Set x64 Release build as default
This commit is contained in:
Yanbing 2017-01-13 12:03:42 -08:00 committed by Manoj Ampalam
parent 50e4499fe0
commit 2017ffdff0
5 changed files with 169 additions and 122 deletions

View File

@ -11,12 +11,12 @@ init:
build_script: build_script:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Invoke-AppVeyorBuild Invoke-AppVeyorBuild
after_build: after_build:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Install-OpenSSH Install-OpenSSH
- ps: Write-Verbose "Restart computer ..." - ps: Write-Verbose "Restart computer ..."
- ps: Restart-Computer -ComputerName localhost -Force - ps: Restart-Computer -ComputerName localhost -Force
@ -25,19 +25,19 @@ after_build:
before_test: before_test:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Install-TestDependencies Install-TestDependencies
test_script: test_script:
- cmd: | - cmd: |
"%ProgramFiles%\PowerShell\6.0.0.12\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\";Run-OpenSSHTests" "%ProgramFiles%\PowerShell\6.0.0.14\powershell.exe" -Command "Import-Module \"%APPVEYOR_BUILD_FOLDER%\contrib\win32\openssh\AppVeyor.psm1\" -WarningAction SilentlyContinue;Run-OpenSSHTests"
after_test: after_test:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Upload-OpenSSHTestResults Upload-OpenSSHTestResults
on_finish: on_finish:
- ps: | - ps: |
Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 Import-Module $env:APPVEYOR_BUILD_FOLDER\contrib\win32\openssh\AppVeyor.psm1 -WarningAction SilentlyContinue
Publish-Artifact Publish-Artifact

View File

@ -1,6 +1,26 @@
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
Import-Module $PSScriptRoot\build.psm1 Import-Module $PSScriptRoot\build.psm1
$repoRoot = Get-RepositoryRoot $repoRoot = Get-RepositoryRoot
$script:logFile = join-path $repoRoot.FullName "appveyorlog.log"
<#
Called by Write-BuildMsg to write to the build log, if it exists.
#>
function Write-Log
{
param
(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $Message
)
# write it to the log file, if present.
if (-not ([string]::IsNullOrEmpty($script:logFile)))
{
Add-Content -Path $script:logFile -Value $Message
}
}
# Sets a build variable # Sets a build variable
Function Set-BuildVariable Function Set-BuildVariable
@ -53,7 +73,7 @@ function Invoke-AppVeyorFull
Install-TestDependencies Install-TestDependencies
& "$env:ProgramFiles\PowerShell\6.0.0.12\powershell.exe" -Command {Import-Module $($repoRoot.FullName)\contrib\win32\openssh\AppVeyor.psm1;Run-OpenSSHTests -uploadResults} & "$env:ProgramFiles\PowerShell\6.0.0.12\powershell.exe" -Command {Import-Module $($repoRoot.FullName)\contrib\win32\openssh\AppVeyor.psm1;Run-OpenSSHTests -uploadResults}
Run-OpenSSHTests Run-OpenSSHTests
Publish-Artifact Publish-Artifact
} }
finally { finally {
if($APPVEYOR_SCHEDULED_BUILD -and $env:APPVEYOR_SCHEDULED_BUILD) if($APPVEYOR_SCHEDULED_BUILD -and $env:APPVEYOR_SCHEDULED_BUILD)
@ -66,10 +86,8 @@ function Invoke-AppVeyorFull
# Implements the AppVeyor 'build_script' step # Implements the AppVeyor 'build_script' step
function Invoke-AppVeyorBuild function Invoke-AppVeyorBuild
{ {
Start-SSHBuild -Configuration Release -NativeHostArch x64 -Verbose Start-SSHBuild -Configuration Release -NativeHostArch x64
Start-SSHBuild -Configuration Debug -NativeHostArch x64 -Verbose Start-SSHBuild -Configuration Debug -NativeHostArch x86
Start-SSHBuild -Configuration Release -NativeHostArch x86 -Verbose
Start-SSHBuild -Configuration Debug -NativeHostArch x86 -Verbose
} }
<# <#
@ -83,8 +101,8 @@ function Invoke-MSIEXEC
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string] $InstallFile [string] $InstallFile
) )
Write-Verbose "Installing $InstallFile..." Write-Log -Message "Installing $InstallFile..."
$arguments = @( $arguments = @(
"/i" "/i"
"`"$InstallFile`"" "`"$InstallFile`""
@ -93,10 +111,10 @@ function Invoke-MSIEXEC
) )
$process = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -PassThru $process = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -PassThru
if ($process.ExitCode -eq 0){ if ($process.ExitCode -eq 0){
Write-Output "$InstallFile has been successfully installed" Write-Log -Message "$InstallFile has been successfully installed."
} }
else { else {
Write-Output "installer exit code $($process.ExitCode) for file $($InstallFile)" Write-Log -Message "installer exit code $($process.ExitCode) for file $($InstallFile)"
} }
return $process.ExitCode return $process.ExitCode
@ -108,13 +126,13 @@ function Invoke-MSIEXEC
#> #>
function Install-PSCoreFromGithub function Install-PSCoreFromGithub
{ {
$downloadLocation = Download-PSCoreMSI $downloadLocation = Download-PSCoreMSI
Write-Output "Installing PSCore ..." Write-Log -Message "Installing PSCore ..."
if(-not [string]::IsNullOrEmpty($downloadLocation)) if(-not [string]::IsNullOrEmpty($downloadLocation))
{ {
$processExitCode = Invoke-MSIEXEC -InstallFile $downloadLocation $processExitCode = Invoke-MSIEXEC -InstallFile $downloadLocation
Write-Output "Process exitcode: $processExitCode" Write-Log -Message "Process exitcode: $processExitCode"
} }
} }
@ -125,27 +143,27 @@ function Install-PSCoreFromGithub
function Get-PSCoreMSIDownloadURL function Get-PSCoreMSIDownloadURL
{ {
$osversion = [String][Environment]::OSVersion.Version $osversion = [String][Environment]::OSVersion.Version
Write-Host "osversion:$osversion"
if($osversion.StartsWith("6")) if($osversion.StartsWith("6"))
{ {
if ($($env:PROCESSOR_ARCHITECTURE).Contains('64')) if ($($env:PROCESSOR_ARCHITECTURE).Contains('64'))
{ {
return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.12/PowerShell_6.0.0.12-alpha.12-win81-x64.msi' return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/PowerShell_6.0.0.14-alpha.14-win81-x64.msi'
} }
else else
{ {
return '' return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/PowerShell_6.0.0.14-alpha.14-win7-x86.msi'
} }
} }
elseif ($osversion.Contains("10.0")) elseif ($osversion.Contains("10.0"))
{ {
if ($($env:PROCESSOR_ARCHITECTURE).Contains('64')) if ($($env:PROCESSOR_ARCHITECTURE).Contains('64'))
{ {
return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.12/PowerShell_6.0.0.12-alpha.12-win10-x64.msi' return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/PowerShell_6.0.0.14-alpha.14-win10-x64.msi'
} }
else else
{ {
return '' return 'https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/PowerShell_6.0.0.14-alpha.14-win7-x86.msi'
} }
} }
} }
@ -158,14 +176,14 @@ function Download-PSCoreMSI
{ {
$url = Get-PSCoreMSIDownloadURL $url = Get-PSCoreMSIDownloadURL
if([string]::IsNullOrEmpty($url)) if([string]::IsNullOrEmpty($url))
{ {
Write-Output "url is empty" Write-Log -Message "url is empty"
return '' return ''
} }
$parsed = $url.Substring($url.LastIndexOf("/") + 1) $parsed = $url.Substring($url.LastIndexOf("/") + 1)
if(-not (Test-path "$env:SystemDrive\PScore" -PathType Container)) if(-not (Test-path "$env:SystemDrive\PScore" -PathType Container))
{ {
New-Item -ItemType Directory -Force -Path "$env:SystemDrive\PScore" | out-null $null = New-Item -ItemType Directory -Force -Path "$env:SystemDrive\PScore" | out-null
} }
$downloadLocation = "$env:SystemDrive\PScore\$parsed" $downloadLocation = "$env:SystemDrive\PScore\$parsed"
if(-not (Test-path $downloadLocation -PathType Leaf)) if(-not (Test-path $downloadLocation -PathType Leaf))
@ -196,16 +214,15 @@ function Install-TestDependencies
$isModuleAvailable = Get-Module 'Pester' -ListAvailable $isModuleAvailable = Get-Module 'Pester' -ListAvailable
if (-not ($isModuleAvailable)) if (-not ($isModuleAvailable))
{ {
Write-Output 'Installing Pester...' Write-Log -Message "Installing Pester..."
choco install Pester -y --force choco install Pester -y --force --limitoutput
} }
if ( -not (Test-Path "$env:ProgramData\chocolatey\lib\sysinternals\tools" ) ) { if ( -not (Test-Path "$env:ProgramData\chocolatey\lib\sysinternals\tools" ) ) {
Write-Output "sysinternals not present. Installing sysinternals." Write-Log -Message "sysinternals not present. Installing sysinternals."
choco install sysinternals -y choco install sysinternals -y --force --limitoutput
} }
Write-Output "Installing pscore..."
Install-PSCoreFromGithub Install-PSCoreFromGithub
} }
<# <#
@ -219,8 +236,8 @@ function Install-OpenSSH
( (
[string] $OpenSSHDir = "$env:SystemDrive\OpenSSH", [string] $OpenSSHDir = "$env:SystemDrive\OpenSSH",
[ValidateSet('Debug', 'Release')] [ValidateSet('Debug', 'Release', '')]
[string]$Configuration = "Debug", [string]$Configuration = "",
[ValidateSet('x86', 'x64', '')] [ValidateSet('x86', 'x64', '')]
[string]$NativeHostArch = "" [string]$NativeHostArch = ""
@ -272,8 +289,8 @@ function Build-Win32OpenSSHPackage
( (
[string] $OpenSSHDir = "$env:SystemDrive\OpenSSH", [string] $OpenSSHDir = "$env:SystemDrive\OpenSSH",
[ValidateSet('Debug', 'Release')] [ValidateSet('Debug', 'Release', '')]
[string]$Configuration = "Debug", [string]$Configuration = "",
[ValidateSet('x86', 'x64', '')] [ValidateSet('x86', 'x64', '')]
[string]$NativeHostArch = "" [string]$NativeHostArch = ""
@ -281,32 +298,49 @@ function Build-Win32OpenSSHPackage
if (-not (Test-Path -Path $OpenSSHDir -PathType Container)) if (-not (Test-Path -Path $OpenSSHDir -PathType Container))
{ {
New-Item -Path $OpenSSHDir -ItemType Directory -Force -ErrorAction Stop $null = New-Item -Path $OpenSSHDir -ItemType Directory -Force -ErrorAction Stop
} }
[string] $platform = $env:PROCESSOR_ARCHITECTURE [string] $platform = $env:PROCESSOR_ARCHITECTURE
if(-not [String]::IsNullOrEmpty($NativeHostArch)) if(-not [String]::IsNullOrEmpty($NativeHostArch))
{ {
$folderName = $NativeHostArch $folderName = $NativeHostArch
if($NativeHostArch -eq 'x86') if($NativeHostArch -ieq 'x86')
{ {
$folderName = "Win32" $folderName = "Win32"
} }
} }
else else
{ {
if($platform -ieq "AMD64") if($platform -ieq "AMD64")
{ {
$folderName = "x64" $folderName = "x64"
} }
else else
{ {
$folderName = "Win32" $folderName = "Win32"
} }
} }
if([String]::IsNullOrEmpty($Configuration))
{
if( $folderName -ieq "Win32" )
{
$RealConfiguration = "Debug"
}
else
{
$RealConfiguration = "Release"
}
}
else
{
$RealConfiguration = $Configuration
}
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot [System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$Configuration" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.exe,*.dll -Exclude *unittest*.* -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.exe,*.dll -Exclude *unittest*.* -Force -ErrorAction Stop
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "contrib\win32\openssh" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "contrib\win32\openssh"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.ps1,sshd_config -Exclude AnalyzeCodeDiff.ps1 -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHDir -Include *.ps1,sshd_config -Exclude AnalyzeCodeDiff.ps1 -Force -ErrorAction Stop
@ -314,8 +348,8 @@ function Build-Win32OpenSSHPackage
$packageName = "rktools.2003" $packageName = "rktools.2003"
$rktoolsPath = "${env:ProgramFiles(x86)}\Windows Resource Kits\Tools\ntrights.exe" $rktoolsPath = "${env:ProgramFiles(x86)}\Windows Resource Kits\Tools\ntrights.exe"
if (-not (Test-Path -Path $rktoolsPath)) if (-not (Test-Path -Path $rktoolsPath))
{ {
Write-Information -MessageData "$packageName not present. Installing $packageName." Write-Log -Message "$packageName not present. Installing $packageName."
choco install $packageName -y --force choco install $packageName -y --force
} }
@ -327,7 +361,7 @@ function Build-Win32OpenSSHPackage
$packageFolder = $env:APPVEYOR_BUILD_FOLDER $packageFolder = $env:APPVEYOR_BUILD_FOLDER
} }
$package = "$packageFolder\Win32OpenSSH$Configuration$folderName.zip" $package = "$packageFolder\Win32OpenSSH$RealConfiguration$folderName.zip"
$allPackage = "$packageFolder\Win32OpenSSH*.zip" $allPackage = "$packageFolder\Win32OpenSSH*.zip"
if (Test-Path $allPackage) if (Test-Path $allPackage)
{ {
@ -349,8 +383,8 @@ function Deploy-OpenSSHTests
( (
[string] $OpenSSHTestDir = "$env:SystemDrive\OpenSSH", [string] $OpenSSHTestDir = "$env:SystemDrive\OpenSSH",
[ValidateSet('Debug', 'Release')] [ValidateSet('Debug', 'Release', '')]
[string]$Configuration = "Debug", [string]$Configuration = "",
[ValidateSet('x86', 'x64', '')] [ValidateSet('x86', 'x64', '')]
[string]$NativeHostArch = "" [string]$NativeHostArch = ""
@ -358,7 +392,7 @@ function Deploy-OpenSSHTests
if (-not (Test-Path -Path $OpenSSHTestDir -PathType Container)) if (-not (Test-Path -Path $OpenSSHTestDir -PathType Container))
{ {
New-Item -Path $OpenSSHTestDir -ItemType Directory -Force -ErrorAction Stop $null = New-Item -Path $OpenSSHTestDir -ItemType Directory -Force -ErrorAction Stop
} }
[string] $platform = $env:PROCESSOR_ARCHITECTURE [string] $platform = $env:PROCESSOR_ARCHITECTURE
@ -381,6 +415,22 @@ function Deploy-OpenSSHTests
$folderName = "Win32" $folderName = "Win32"
} }
} }
if([String]::IsNullOrEmpty($Configuration))
{
if( $folderName -ieq "Win32" )
{
$RealConfiguration = "Debug"
}
else
{
$RealConfiguration = "Release"
}
}
else
{
$RealConfiguration = $Configuration
}
[System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot [System.IO.DirectoryInfo] $repositoryRoot = Get-RepositoryRoot
@ -388,9 +438,8 @@ function Deploy-OpenSSHTests
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1 -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Include *.ps1,*.psm1 -Force -ErrorAction Stop
$sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$Configuration" $sourceDir = Join-Path $repositoryRoot.FullName -ChildPath "bin\$folderName\$RealConfiguration"
Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Exclude ssh-agent.exe, sshd.exe -Force -ErrorAction Stop Copy-Item -Path "$sourceDir\*" -Destination $OpenSSHTestDir -Exclude ssh-agent.exe, sshd.exe -Force -ErrorAction Stop
} }
@ -419,10 +468,8 @@ function Add-BuildLog
) )
if (Test-Path -Path $buildLog) if (Test-Path -Path $buildLog)
{ {
Write-Output "Adding $buildLog to local artifacts"
$null = $artifacts.Add($buildLog) $null = $artifacts.Add($buildLog)
Write-Output "Adding $buildLog to local artifacts- completed"
} }
else else
{ {
@ -449,14 +496,10 @@ function Add-Artifact
$files = Get-ChildItem -Path $FileToAdd -ErrorAction Ignore $files = Get-ChildItem -Path $FileToAdd -ErrorAction Ignore
if ($files -ne $null) if ($files -ne $null)
{ {
$files | % { $files | % {
Write-Output "Adding $($_.FullName) to local artifacts" $null = $artifacts.Add($_.FullName)
$null = $artifacts.Add($_.FullName) }
Write-Output "Adding $($_.FullName) to local artifacts- completed"
}
} }
else else
{ {
@ -480,13 +523,11 @@ function Publish-Artifact
} }
Add-Artifact -artifacts $artifacts -FileToAdd "$packageFolder\Win32OpenSSH*.zip" Add-Artifact -artifacts $artifacts -FileToAdd "$packageFolder\Win32OpenSSH*.zip"
Add-Artifact -artifacts $artifacts -FileToAdd "$packageFolder\OpenSSH\UnitTestResults.txt" Add-Artifact -artifacts $artifacts -FileToAdd "$env:SystemDrive\OpenSSH\UnitTestResults.txt"
Add-Artifact -artifacts $artifacts -FileToAdd "$script:logFile"
# Get the build.log file for each build configuration # Get the build.log file for each build configuration
#Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Release -NativeHostArch x86) Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName)
#Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Debug -NativeHostArch x86)
#Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Release -NativeHostArch x64)
Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Debug -NativeHostArch x64)
foreach ($artifact in $artifacts) foreach ($artifact in $artifacts)
{ {
@ -505,11 +546,11 @@ function Run-OpenSSHPesterTest
param($testRoot, $outputXml) param($testRoot, $outputXml)
# Discover all CI tests and run them. # Discover all CI tests and run them.
Push-Location $testRoot Push-Location $testRoot
Write-Output "Running OpenSSH Pester tests..." Write-Log -Message "Running OpenSSH Pester tests..."
$testFolders = Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique $testFolders = Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique
Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $outputXml -Tag 'CI' Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $outputXml -Tag 'CI'
Pop-Location Pop-Location
} }
@ -522,8 +563,8 @@ function Run-OpenSSHUnitTest
param($testRoot, $unitTestOutputFile) param($testRoot, $unitTestOutputFile)
# Discover all CI tests and run them. # Discover all CI tests and run them.
Push-Location $testRoot Push-Location $testRoot
Write-Output "Running OpenSSH unit tests..." Write-Log -Message "Running OpenSSH unit tests..."
if (Test-Path $unitTestOutputFile) if (Test-Path $unitTestOutputFile)
{ {
Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue
@ -534,13 +575,13 @@ function Run-OpenSSHUnitTest
if ($unitTestFiles -ne $null) if ($unitTestFiles -ne $null)
{ {
$unitTestFiles | % { $unitTestFiles | % {
Write-Output "Running OpenSSH unit $($_.FullName)..." Write-Log -Message "Running OpenSSH unit $($_.FullName)..."
& $_.FullName >> $unitTestOutputFile & $_.FullName >> $unitTestOutputFile
$errorCode = $LASTEXITCODE $errorCode = $LASTEXITCODE
if ($errorCode -ne 0) if ($errorCode -ne 0)
{ {
$testFailed = $true $testFailed = $true
Write-Output "$($_.FullName) test failed for OpenSSH.`nExitCode: $error" Write-Log -Message "$($_.FullName) test failed for OpenSSH.`nExitCode: $error"
} }
} }
@ -614,6 +655,5 @@ function Upload-OpenSSHTestResults
if ($env:APPVEYOR_JOB_ID) if ($env:APPVEYOR_JOB_ID)
{ {
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile)) (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
} }
} }

View File

@ -133,15 +133,14 @@ function Write-BuildMsg
Verifies all tools and dependencies required for building Open SSH are installed on the machine. Verifies all tools and dependencies required for building Open SSH are installed on the machine.
#> #>
function Start-SSHBootstrap function Start-SSHBootstrap
{ {
[bool] $silent = -not $script:Verbose
Set-StrictMode -Version Latest Set-StrictMode -Version Latest
Write-BuildMsg -AsInfo -Message "Checking tools and dependencies" Write-BuildMsg -AsInfo -Message "Checking tools and dependencies" -Silent:$silent
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE') $machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
$newMachineEnvironmentPath = $machinePath $newMachineEnvironmentPath = $machinePath
# NOTE: Unless -Verbose is specified, most informational output will only go to the log file.
[bool] $silent = -not $script:Verbose
# Install chocolatey # Install chocolatey
$chocolateyPath = "$env:AllUsersProfile\chocolatey\bin" $chocolateyPath = "$env:AllUsersProfile\chocolatey\bin"
@ -151,18 +150,18 @@ function Start-SSHBootstrap
} }
else else
{ {
Write-BuildMsg -AsInfo -Message "Chocolatey not present. Installing chocolatey." Write-BuildMsg -AsInfo -Message "Chocolatey not present. Installing chocolatey." -Silent:$silent
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower()))) if (-not ($machinePath.ToLower().Contains($chocolateyPath.ToLower())))
{ {
Write-BuildMsg -AsVerbose -Message "Adding $chocolateyPath to Path environment variable" Write-BuildMsg -AsVerbose -Message "Adding $chocolateyPath to Path environment variable" -Silent:$silent
$newMachineEnvironmentPath += ";$chocolateyPath" $newMachineEnvironmentPath += ";$chocolateyPath"
$env:Path += ";$chocolateyPath" $env:Path += ";$chocolateyPath"
} }
else else
{ {
Write-BuildMsg -AsVerbose -Message "$chocolateyPath already present in Path environment variable" Write-BuildMsg -AsVerbose -Message "$chocolateyPath already present in Path environment variable" -Silent:$silent
} }
} }
@ -170,7 +169,7 @@ function Start-SSHBootstrap
$gitCmdPath = "$env:ProgramFiles\git\cmd" $gitCmdPath = "$env:ProgramFiles\git\cmd"
if (-not ($machinePath.ToLower().Contains($gitCmdPath.ToLower()))) if (-not ($machinePath.ToLower().Contains($gitCmdPath.ToLower())))
{ {
Write-BuildMsg -AsVerbose -Message "Adding $gitCmdPath to Path environment variable" Write-BuildMsg -AsVerbose -Message "Adding $gitCmdPath to Path environment variable" -Silent:$silent
$newMachineEnvironmentPath = "$gitCmdPath;$newMachineEnvironmentPath" $newMachineEnvironmentPath = "$gitCmdPath;$newMachineEnvironmentPath"
} }
else else
@ -186,7 +185,7 @@ function Start-SSHBootstrap
if (-not ($machinePath.ToLower().Contains($nativeMSBuildPath.ToLower()))) if (-not ($machinePath.ToLower().Contains($nativeMSBuildPath.ToLower())))
{ {
Write-BuildMsg -AsVerbose -Message "Adding $nativeMSBuildPath to Path environment variable" Write-BuildMsg -AsVerbose -Message "Adding $nativeMSBuildPath to Path environment variable" -Silent:$silent
$newMachineEnvironmentPath += ";$nativeMSBuildPath" $newMachineEnvironmentPath += ";$nativeMSBuildPath"
$env:Path += ";$nativeMSBuildPath" $env:Path += ";$nativeMSBuildPath"
} }
@ -207,8 +206,8 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $nasmPath -PathType Container)) if (-not (Test-Path -Path $nasmPath -PathType Container))
{ {
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --force --execution-timeout 10000 choco install $packageName -y --force --limitoutput --execution-timeout 10000
} }
else else
{ {
@ -221,9 +220,9 @@ function Start-SSHBootstrap
if ($null -eq $VSPackageInstalled) if ($null -eq $VSPackageInstalled)
{ {
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName." -Silent:$silent
$adminFilePath = "$script:OpenSSHRoot\contrib\win32\openssh\VSWithBuildTools.xml" $adminFilePath = "$script:OpenSSHRoot\contrib\win32\openssh\VSWithBuildTools.xml"
choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --execution-timeout 10000 choco install $packageName -packageParameters "--AdminFile $adminFilePath" -y --force --limitoutput --execution-timeout 10000
} }
else else
{ {
@ -236,8 +235,8 @@ function Start-SSHBootstrap
if (-not (Test-Path -Path $sdkPath)) if (-not (Test-Path -Path $sdkPath))
{ {
Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName." Write-BuildMsg -AsInfo -Message "Windows 8.1 SDK not present. Installing $packageName." -Silent:$silent
choco install $packageName -y --force choco install $packageName -y --limitoutput --force
} }
else else
{ {
@ -262,7 +261,7 @@ function Start-SSHBootstrap
$item = Get-Item(Join-Path -Path $env:VS140COMNTOOLS -ChildPath '../../vc') $item = Get-Item(Join-Path -Path $env:VS140COMNTOOLS -ChildPath '../../vc')
$script:vcPath = $item.FullName $script:vcPath = $item.FullName
Write-BuildMsg -AsVerbose -Message "vcPath: $script:vcPath" Write-BuildMsg -AsVerbose -Message "vcPath: $script:vcPath" -Silent:$silent
if ((Test-Path -Path "$script:vcPath\vcvarsall.bat") -eq $false) if ((Test-Path -Path "$script:vcPath\vcvarsall.bat") -eq $false)
{ {
Write-BuildMsg -AsError -ErrorAction Stop -Message "Could not find Visual Studio vcvarsall.bat at" + $script:vcPath Write-BuildMsg -AsError -ErrorAction Stop -Message "Could not find Visual Studio vcvarsall.bat at" + $script:vcPath
@ -270,16 +269,18 @@ function Start-SSHBootstrap
} }
function Clone-Win32OpenSSH function Clone-Win32OpenSSH
{ {
[bool] $silent = -not $script:Verbose
$win32OpenSSHPath = join-path $script:gitRoot "Win32-OpenSSH" $win32OpenSSHPath = join-path $script:gitRoot "Win32-OpenSSH"
if (-not (Test-Path -Path $win32OpenSSHPath -PathType Container)) if (-not (Test-Path -Path $win32OpenSSHPath -PathType Container))
{ {
Write-BuildMsg -AsInfo -Message "clone repo Win32-OpenSSH" Write-BuildMsg -AsInfo -Message "clone repo Win32-OpenSSH" -Silent:$silent
Push-Location $gitRoot Push-Location $gitRoot
git clone -q --recursive https://github.com/PowerShell/Win32-OpenSSH.git $win32OpenSSHPath git clone -q --recursive https://github.com/PowerShell/Win32-OpenSSH.git $win32OpenSSHPath
Pop-Location Pop-Location
} }
Write-BuildMsg -AsInfo -Message "pull latest from repo Win32-OpenSSH" Write-BuildMsg -AsInfo -Message "pull latest from repo Win32-OpenSSH" -Silent:$silent
Push-Location $win32OpenSSHPath Push-Location $win32OpenSSHPath
git fetch -q origin git fetch -q origin
git checkout -qf L1-Prod git checkout -qf L1-Prod
@ -287,9 +288,11 @@ function Clone-Win32OpenSSH
} }
function Copy-OpenSSLSDK function Copy-OpenSSLSDK
{ {
[bool] $silent = -not $script:Verbose
$sourcePath = Join-Path $script:gitRoot "Win32-OpenSSH\contrib\win32\openssh\OpenSSLSDK" $sourcePath = Join-Path $script:gitRoot "Win32-OpenSSH\contrib\win32\openssh\OpenSSLSDK"
Write-BuildMsg -AsInfo -Message "copying $sourcePath" Write-BuildMsg -AsInfo -Message "copying $sourcePath" -Silent:$silent
Copy-Item -Container -Path $sourcePath -Destination $PSScriptRoot -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable e Copy-Item -Container -Path $sourcePath -Destination $PSScriptRoot -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable e
if($e -ne $null) if($e -ne $null)
{ {
@ -306,7 +309,7 @@ function Start-SSHBuild
[string]$NativeHostArch = "x64", [string]$NativeHostArch = "x64",
[ValidateSet('Debug', 'Release', '')] [ValidateSet('Debug', 'Release', '')]
[string]$Configuration = "Debug" [string]$Configuration = "Release"
) )
Set-StrictMode -Version Latest Set-StrictMode -Version Latest
$script:BuildLogFile = $null $script:BuildLogFile = $null
@ -321,16 +324,16 @@ function Start-SSHBuild
if($PSBoundParameters.ContainsKey("Verbose")) if($PSBoundParameters.ContainsKey("Verbose"))
{ {
$script:Verbose = ($PSBoundParameters['Verbose']).IsPresent $script:Verbose = ($PSBoundParameters['Verbose']).IsPresent
} }
[bool] $silent = -not $script:Verbose
$script:BuildLogFile = Get-BuildLogFile -root $repositoryRoot.FullName -Configuration $Configuration -NativeHostArch $NativeHostArch $script:BuildLogFile = Get-BuildLogFile -root $repositoryRoot.FullName -Configuration $Configuration -NativeHostArch $NativeHostArch
if (Test-Path -Path $script:BuildLogFile) if (Test-Path -Path $script:BuildLogFile)
{ {
Remove-Item -Path $script:BuildLogFile Remove-Item -Path $script:BuildLogFile
} }
Write-BuildMsg -AsInfo -Message "Starting Open SSH build." Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)"
Write-BuildMsg -AsInfo -Message "Build Log: $($script:BuildLogFile)"
Start-SSHBootstrap Start-SSHBootstrap
@ -338,20 +341,19 @@ function Start-SSHBuild
Copy-OpenSSLSDK Copy-OpenSSLSDK
$msbuildCmd = "msbuild.exe" $msbuildCmd = "msbuild.exe"
$solutionFile = Get-SolutionFile -root $repositoryRoot.FullName $solutionFile = Get-SolutionFile -root $repositoryRoot.FullName
$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic") $cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/noconlog", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
#$cmdMsg = @("${solutionFile}", "/p:Platform=${NativeHostArch}", "/p:Configuration=${Configuration}", "/nologo", "/fl", "/flp:LogFile=${script:BuildLogFile}`;Append`;Verbosity=diagnostic")
Write-Information -MessageData $msbuildCmd
Write-Information -MessageData $cmdMsg
& $msbuildCmd $cmdMsg & $msbuildCmd $cmdMsg
$errorCode = $LASTEXITCODE $errorCode = $LASTEXITCODE
if ($errorCode -ne 0) if ($errorCode -ne 0)
{ {
Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $error" Write-BuildMsg -AsError -ErrorAction Stop -Message "Build failed for OpenSSH.`nExitCode: $error."
} }
Write-BuildMsg -AsVerbose -Message "Finished Open SSH build." Write-BuildMsg -AsInfo -Message "SSH build passed."
} }
function Get-BuildLogFile function Get-BuildLogFile
@ -366,10 +368,10 @@ function Get-BuildLogFile
[string]$NativeHostArch = "x64", [string]$NativeHostArch = "x64",
[ValidateSet('Debug', 'Release', '')] [ValidateSet('Debug', 'Release', '')]
[string]$Configuration = "Debug" [string]$Configuration = "Release"
) )
return Join-Path -Path $root -ChildPath "contrib\win32\openssh\OpenSSH$($Configuration)$($NativeHostArch).log" return Join-Path -Path $root -ChildPath "contrib\win32\openssh\OpenSSH$($Configuration)$($NativeHostArch).log"
} }
function Get-SolutionFile function Get-SolutionFile
@ -414,4 +416,4 @@ function Get-RepositoryRoot
throw new-object System.IO.DirectoryNotFoundException("Could not find the root of the GIT repository") throw new-object System.IO.DirectoryNotFoundException("Could not find the root of the GIT repository")
} }
Export-ModuleMember -Function Start-SSHBuild, Get-RepositoryRoot, Get-BuildLogFile, Clone-Win32OpenSSH, Copy-OpenSSLSDK Export-ModuleMember -Function Start-SSHBuild, Get-RepositoryRoot, Get-BuildLogFile, Clone-Win32OpenSSH, Copy-OpenSSLSDK, Write-BuildMsg

View File

@ -224,7 +224,12 @@ Class Machine
} }
[void] CleanupClient() { [void] CleanupClient() {
Remove-item -path $($this.ClientKeyDirectory) -force -Recurse -ea silentlycontinue Remove-item -path $($this.ClientKeyDirectory) -force -Recurse -ea silentlycontinue
$sshPath = split-path $this.knownHostOfCurrentUser -Parent
if(Test-Path $sshPath -PathType Container )
{
Remove-item -path $sshPath -force -Recurse
}
$this.CleanupPasswordSetting() $this.CleanupPasswordSetting()
} }

View File

@ -210,10 +210,10 @@ Describe "Tests for scp command" -Tags "CI" {
$client.CleanupPasswordSetting() $client.CleanupPasswordSetting()
} }
It 'File copy with -p and -v options: <Title> ' -TestCases:$testData { It 'File copy with -p options: <Title> ' -TestCases:$testData {
param([string]$Title, $Source, $Destination) param([string]$Title, $Source, $Destination)
.\scp -v -p $Source $Destination .\scp -p $Source $Destination
#validate file content. DestPath is the path to the file. #validate file content. DestPath is the path to the file.
$equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0 $equal = @(Compare-Object (Get-ChildItem -path $SourceFilePath) (Get-ChildItem -path $DestinationFilePath) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true $equal | Should Be $true
@ -222,7 +222,7 @@ Describe "Tests for scp command" -Tags "CI" {
It 'Directory recursive copy with -p and -v options: <Title> ' -TestCases:$testData1 { It 'Directory recursive copy with -p and -v options: <Title> ' -TestCases:$testData1 {
param([string]$Title, $Source, $Destination) param([string]$Title, $Source, $Destination)
.\scp -r -v $Source $Destination .\scp -r -p $Source $Destination
$equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0 $equal = @(Compare-Object (Get-Item -path $SourceDir ) (Get-Item -path (join-path $DestinationDir $SourceDirName) ) -Property Name, Length, LastWriteTime.DateTime).Length -eq 0
$equal | Should Be $true $equal | Should Be $true