@@ -299,7 +299,10 @@ function Package-OpenSSH
299299 [string ]$NativeHostArch = " x64" ,
300300
301301 [ValidateSet (' Debug' , ' Release' , ' ' )]
302- [string ]$Configuration = " Release"
302+ [string ]$Configuration = " Release" ,
303+
304+ # Copy payload to DestinationPath instead of packaging
305+ [string ]$DestinationPath = " "
303306 )
304307
305308 [System.IO.DirectoryInfo ] $repositoryRoot = Get-RepositoryRoot
@@ -311,9 +314,8 @@ function Package-OpenSSH
311314 }
312315 $buildDir = Join-Path $repositoryRoot (" bin\" + $folderName + " \" + $Configuration )
313316 $payload = " sshd.exe" , " ssh.exe" , " ssh-agent.exe" , " ssh-add.exe" , " sftp.exe"
314- $payload += " sftp-server.exe" , " scp.exe" , " ssh-lsa.dll " , " ssh- shellhost.exe" , " ssh-keygen.exe"
317+ $payload += " sftp-server.exe" , " scp.exe" , " ssh-shellhost.exe" , " ssh-keygen.exe"
315318 $payload += " sshd_config" , " install-sshd.ps1" , " uninstall-sshd.ps1"
316- $payload += " install-sshlsa.ps1" , " uninstall-sshlsa.ps1"
317319
318320 $packageName = " OpenSSH-Win64"
319321 if ($NativeHostArch -eq ' x86' ) {
@@ -343,12 +345,29 @@ function Package-OpenSSH
343345 }
344346 }
345347
346- Remove-Item ($packageDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
347- Compress-Archive - Path $packageDir - DestinationPath ($packageDir + ' .zip' )
348+ if ($DestinationPath -ne " " ) {
349+ if (Test-Path $DestinationPath ) {
350+ Remove-Item $DestinationPath \* - Force
351+ }
352+ else {
353+ New-Item - ItemType Directory $DestinationPath | Out-Null
354+ }
355+ Copy-Item - Path $packageDir \* - Destination $DestinationPath - Force - Recurse
356+ }
357+ else {
358+ Remove-Item ($packageDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
359+ Compress-Archive - Path $packageDir - DestinationPath ($packageDir + ' .zip' )
360+ }
348361 Remove-Item $packageDir - Recurse - Force - ErrorAction SilentlyContinue
349362
350- Remove-Item ($symbolsDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
351- Compress-Archive - Path $symbolsDir - DestinationPath ($symbolsDir + ' .zip' )
363+
364+ if ($DestinationPath -ne " " ) {
365+ Copy-Item - Path $symbolsDir \* - Destination $DestinationPath - Force - Recurse
366+ }
367+ else {
368+ Remove-Item ($symbolsDir + ' .zip' ) - Force - ErrorAction SilentlyContinue
369+ Compress-Archive - Path $symbolsDir - DestinationPath ($symbolsDir + ' .zip' )
370+ }
352371 Remove-Item $symbolsDir - Recurse - Force - ErrorAction SilentlyContinue
353372}
354373
@@ -436,97 +455,41 @@ function Get-SolutionFile
436455
437456<#
438457 . Synopsis
439- Deploy all required files to build a package and create zip file.
458+ Deploy all required files to a location and install the binaries
440459#>
441- function Deploy-Win32OpenSSHBinaries
460+ function Install-OpenSSH
442461{
443462 [CmdletBinding ()]
444463 param
445- (
464+ (
446465 [ValidateSet (' Debug' , ' Release' , ' ' )]
447466 [string ]$Configuration = " " ,
467+
448468 [ValidateSet (' x86' , ' x64' , ' ' )]
449469 [string ]$NativeHostArch = " " ,
470+
450471 [string ]$OpenSSHDir = " $env: SystemDrive \OpenSSH"
451472 )
452473
453- if (-not ( Test-Path - Path $OpenSSHDir - PathType Container) )
474+ if ($Configuration -eq " " )
454475 {
455- $null = New-Item - Path $OpenSSHDir - ItemType Directory - Force - ErrorAction Stop
476+ $Configuration = ' Release '
456477 }
457478
458- [string ] $platform = $env: PROCESSOR_ARCHITECTURE
459- if (-not [String ]::IsNullOrEmpty($NativeHostArch ))
479+ if ($NativeHostArch -eq " " )
460480 {
461- $folderName = $NativeHostArch
462- if ($NativeHostArch -ieq ' x86' )
463- {
464- $folderName = " Win32"
465- }
466- }
467- else
468- {
469- if ($platform -ieq " AMD64" )
470- {
471- $folderName = " x64"
472- }
473- else
474- {
475- $folderName = " Win32"
476- }
477- }
478-
479- if ([String ]::IsNullOrEmpty($Configuration ))
480- {
481- if ( $folderName -ieq " Win32" )
482- {
483- $RealConfiguration = " Debug"
484- }
485- else
486- {
487- $RealConfiguration = " Release"
481+ $NativeHostArch = ' x64'
482+ if ($env: PROCESSOR_ARCHITECTURE -eq ' x86' ) {
483+ $NativeHostArch = ' x86'
488484 }
489485 }
490- else
491- {
492- $RealConfiguration = $Configuration
493- }
494486
495- [System.IO.DirectoryInfo ] $repositoryRoot = Get-RepositoryRoot
496-
497- $sourceDir = Join-Path $repositoryRoot.FullName - ChildPath " bin\$folderName \$RealConfiguration "
498- if ((Get-Service ssh- agent - ErrorAction Ignore) -ne $null ) {
499- Stop-Service ssh- agent - Force
500- }
501- Copy-Item - Path " $sourceDir \*" - Destination $OpenSSHDir - Include * .exe, * .dll - Exclude * unittest* .* - Force - ErrorAction Stop
502- $sourceDir = Join-Path $repositoryRoot.FullName - ChildPath " contrib\win32\openssh"
503- Copy-Item - Path " $sourceDir \*" - Destination $OpenSSHDir - Include * .ps1, sshd_config - Exclude AnalyzeCodeDiff.ps1 - Force - ErrorAction Stop
504- }
505-
506- <#
507- . Synopsis
508- Deploy all required files to a location and install the binaries
509- #>
510- function Install-OpenSSH
511- {
512- [CmdletBinding ()]
513- param
514- (
515- [ValidateSet (' Debug' , ' Release' , ' ' )]
516- [string ]$Configuration = " " ,
517-
518- [ValidateSet (' x86' , ' x64' , ' ' )]
519- [string ]$NativeHostArch = " " ,
520-
521- [string ]$OpenSSHDir = " $env: SystemDrive \OpenSSH"
522- )
523-
524- Deploy-Win32OpenSSHBinaries @PSBoundParameters
487+ Package- OpenSSH - NativeHostArch $NativeHostArch - Configuration $Configuration - DestinationPath $OpenSSHDir
525488
526489 Push-Location $OpenSSHDir
527490 & ( " $OpenSSHDir \install-sshd.ps1" )
528491 .\ssh-keygen.exe - A
529- & ( " $OpenSSHDir \install-sshlsa.ps1 " )
492+
530493
531494 # machine will be reboot after Install-openssh anyway
532495 $machinePath = [Environment ]::GetEnvironmentVariable(' Path' , ' MACHINE' )
0 commit comments