From a8a7de9ee6350bfe7585e623a7bdfda25dd7615a Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 17 Mar 2017 18:01:08 -0600 Subject: [PATCH] began converting all post build actions to powershell --- Tools/postbuild_installer.ps1 | 38 ++++++++++++++++++ Tools/postbuild_mremotev1.ps1 | 72 +++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 Tools/postbuild_installer.ps1 create mode 100644 Tools/postbuild_mremotev1.ps1 diff --git a/Tools/postbuild_installer.ps1 b/Tools/postbuild_installer.ps1 new file mode 100644 index 000000000..4052fe79f --- /dev/null +++ b/Tools/postbuild_installer.ps1 @@ -0,0 +1,38 @@ +param ( + [string] + [Parameter(Mandatory=$true)] + $SolutionDir, + + [string] + [Parameter(Mandatory=$true)] + $TargetDir, + + [string] + [Parameter(Mandatory=$true)] + $TargetFileName, + + [string] + [Parameter(Mandatory=$true)] + $ConfigurationName +) + +$certificatePath = "C:\mRemoteNG_code_signing_cert.pfx" +$path_signFilesScript = Join-Path -Path $SolutionDir -ChildPath "Tools\signfiles.ps1" +$path_installerRenameScript = Join-Path -Path $SolutionDir -ChildPath "Tools\rename_installer_with_version.ps1" +$path_copyToReleaseScript = Join-Path -Path $SolutionDir -ChildPath "Tools\copy_release_installer.ps1" + + +# Sign MSI if we are building a release version and the certificate is available +if (($ConfigurationName -match "Release") -and (Test-Path -Path $certificatePath -PathType Leaf)) { + powershell.exe -ExecutionPolicy Bypass -File $path_signFilesScript $TargetDir +} + + +# Rename MSI to include version number +powershell.exe -ExecutionPolicy Bypass -File $path_installerRenameScript -SolutionDir $SolutionDir + + +# Copy MSI to Release folder +if ($ConfigurationName -match "Release") { + powershell.exe -ExecutionPolicy Bypass -File $path_copyToReleaseScript -SourcePath $TargetDir -DestinationDir (Join-Path -Path $SolutionDir -ChildPath "Release") +} \ No newline at end of file diff --git a/Tools/postbuild_mremotev1.ps1 b/Tools/postbuild_mremotev1.ps1 new file mode 100644 index 000000000..2a7dc64c7 --- /dev/null +++ b/Tools/postbuild_mremotev1.ps1 @@ -0,0 +1,72 @@ +param ( + [string] + [Parameter(Mandatory=$true)] + $SolutionDir, + + [string] + [Parameter(Mandatory=$true)] + $TargetDir, + + [string] + [Parameter(Mandatory=$true)] + $TargetFileName, + + [string] + [Parameter(Mandatory=$true)] + $ConfigurationName +) + +$certificatePath = "C:\mRemoteNG_code_signing_cert.pfx" +$path_signFilesScript = Join-Path -Path $SolutionDir -ChildPath "Tools\signfiles.ps1" +$path_packageZipScript = Join-Path -Path $SolutionDir -ChildPath "Tools\build-relport.cmd" +$path_HelpFilesDir = Join-Path -Path $TargetDir -ChildPath "Help" +$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName +$path_editBin = @((Resolve-Path -Path "C:\Program Files*\Microsoft Visual Studio*\VC\bin\editbin.exe").Path)[0] + + + +# Copy PuTTYNG +Write-Host "Copy PUTTYNG to correct directory" -ForegroundColor Green +Copy-Item -Path (Join-Path -Path $SolutionDir -ChildPath "mRemoteV1\Resources\PuTTYNG.exe") -Destination $TargetDir -Force + + + +# Move Help files +Write-Host "Move Help files to correct directory" -ForegroundColor Green +if (Test-Path -Path $path_HelpFilesDir) { + Remove-Item -Path $path_HelpFilesDir -Recurse -Force +} +Move-Item -Path (Join-Path -Path $TargetDir -ChildPath "Resources\Help") -Destination $path_HelpFilesDir -Force +Start-Sleep -Seconds 2 +Remove-Item -Path (Join-Path -Path $TargetDir -ChildPath "Resources") -Recurse -Force + + + +# Set LargeAddressAware +Write-Host "Set LargeAddressAware on binary" -ForegroundColor Green +& $path_editBin "/largeaddressaware $path_outputExe" + + + +# Remove unnecessary files from Release versions +if (($ConfigurationName -match "Release") -and (Test-Path -Path $certificatePath -PathType Leaf)) { + Write-Host "Removing unnecessary files from Release versions" -ForegroundColor Green + Remove-Item -Path (Join-Path -Path $TargetDir -ChildPath "app.publish") -Recurse -Force + Remove-Item -Path $TargetDir -Include @( + "*.pdb", + "*.publish", + "*.xml", + "*.backup", + "*.log", + "*vshost*", + "*.tmp" + ) +} + + + +# Package Zip +if ($ConfigurationName -match "Release" -and $ConfigurationName -match "Portable") { + Write-Host "Package ZIP Release Portable" -ForegroundColor Green + & $path_packageZipScript +} \ No newline at end of file