From 23eaba0d47e6881fe690c6eaba4e972e4f1ee882 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Mon, 20 Jun 2016 11:52:01 -0600 Subject: [PATCH] - Added scripts to rename and copy the MSI installer to the $(SolutionDir)\Release folder - Added conditional post build to run the build-relport script when building the Release Portable configuration --- InstallerProjects/Installer/Installer.wixproj | 25 +++++++++++++++---- Tools/copy_release_installer.ps1 | 13 ++++++++++ Tools/rename_installer_with_version.ps1 | 21 ++++++++++++++++ mRemoteV1/mRemoteV1.csproj | 7 ++++-- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 Tools/copy_release_installer.ps1 create mode 100644 Tools/rename_installer_with_version.ps1 diff --git a/InstallerProjects/Installer/Installer.wixproj b/InstallerProjects/Installer/Installer.wixproj index ddb28f30f..a7b323e47 100644 --- a/InstallerProjects/Installer/Installer.wixproj +++ b/InstallerProjects/Installer/Installer.wixproj @@ -100,6 +100,7 @@ HarvestPath=$(SolutionDir)mRemoteV1\bin\Release;HelpFilesHarvestPath=$(SolutionDir)mRemoteV1\Resources\Help en-US + True en-US @@ -112,13 +113,27 @@ HarvestPath=$(SolutionDir)mRemoteV1\bin\Release Portable;HelpFilesHarvestPath=$(SolutionDir)mRemoteV1\Resources\Help - REM Harvest bin directory of the mRemoteV1 project + set /p buildenv=<buildenv.tmp + +REM Sign MSI +IF EXIST C:\mRemoteNG_code_signing_cert.pfx (powershell "&""$(SolutionDir)Tools\signfiles.ps1""" %27%25cd%25%27) + +REM Rename MSI to include version number +powershell "&""$(SolutionDir)Tools\rename_installer_with_version.ps1""" %27$(SolutionDir)%27 %27!(TargetPath)%27 + +REM Copy MSI to Release folder +IF %25buildenv: Portable=%25==Release (powershell "&""$(SolutionDir)Tools\copy_release_installer.ps1""" %27$(TargetDir)%27 %27$(SolutionDir)Release%27) + + + REM Clean the TargetDir +rmdir /S /Q "$(TargetDir)" + +echo $(ConfigurationName) > buildenv.tmp + +REM Harvest bin directory of the mRemoteV1 project call "$(WIX)bin\heat.exe" dir "$(SolutionDir)mRemoteV1\bin\$(Configuration)" -ag -dr APPLICATIONROOTDIRECTORY -var var.HarvestPath -srd -cg MandatoryComponents -template fragment -out "$(ProjectDir)Fragments\FilesFragment.wxs" -t "$(ProjectDir)Filters\Harvest_Filter.xslt" -v + REM Convert the license file "COPYING.TXT" to "License.rtf" to be shown in the installer GUI call "$(ProjectDir)Resources\Pandoc\pandoc.exe" -s -t rtf -o "$(ProjectDir)\Resources\License.rtf" "$(SolutionDir)COPYING.TXT" - - REM Sign MSI -IF EXIST C:\mRemoteNG_code_signing_cert.pfx (powershell "&""$(SolutionDir)signfiles.ps1""" "%25cd%25") - \ No newline at end of file diff --git a/Tools/copy_release_installer.ps1 b/Tools/copy_release_installer.ps1 new file mode 100644 index 000000000..49b784473 --- /dev/null +++ b/Tools/copy_release_installer.ps1 @@ -0,0 +1,13 @@ +$sourcePath = $args[0] +$destinationDir = $args[1] + +if (!(Test-Path -Path $destinationDir)) +{ + New-Item -Path $destinationDir -ItemType "directory" +} + +$sourceFiles = Get-ChildItem -Path $sourcePath -Recurse | ?{$_.Extension -match "exe|msi"} +foreach ($item in $sourceFiles) +{ + Copy-Item -Path $item.FullName -Destination $destinationDir -Force +} \ No newline at end of file diff --git a/Tools/rename_installer_with_version.ps1 b/Tools/rename_installer_with_version.ps1 new file mode 100644 index 000000000..0633a3598 --- /dev/null +++ b/Tools/rename_installer_with_version.ps1 @@ -0,0 +1,21 @@ +#$solutionDir = $args[0] -replace "\\$" +$solutionDir = "C:\Users\vsparda\Documents\Repositories\mRemoteNG Project\mRemoteNG\" +#$renameTarget = $args[1] +$renameTarget = "C:\Users\vsparda\Documents\Repositories\mRemoteNG Project\mRemoteNG\InstallerProjects\Installer\bin\Release\en-US\mRemoteNG-Installer.msi" +$targetVersionedFile = "$solutionDir\mRemoteV1\bin\Release\mRemoteNG.exe" +$version = &"$solutionDir\Tools\sigcheck.exe" /accepteula -q -n $targetVersionedFile + + +$renameTargetFileObject = Get-Item -Path $renameTarget -ErrorAction SilentlyContinue +if ($renameTargetFileObject) +{ + # Build the new file name + $oldFileName = $renameTargetFileObject.Name + $newFileName = $oldFileName -replace "$("\"+$renameTargetFileObject.Extension)",$("-"+$version+$renameTargetFileObject.Extension) + + # Delete any items that already exist with the new name (effectively an overwrite) + Remove-Item -Path "$($renameTargetFileObject.Directory.FullName)\$newFileName" -ErrorAction SilentlyContinue + + # Rename file + Rename-Item -Path $renameTarget -NewName $newFileName -ErrorAction SilentlyContinue +} \ No newline at end of file diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 6a510d43e..6836eb3fd 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -1203,13 +1203,16 @@ REM Set LargeAddressAware on binary editbin /largeaddressaware mRemoteNG.exe REM Sign binaries -IF EXIST C:\mRemoteNG_code_signing_cert.pfx (powershell "&""$(SolutionDir)signfiles.ps1""" %25cd%25) +IF EXIST C:\mRemoteNG_code_signing_cert.pfx (powershell "&""$(SolutionDir)Tools\signfiles.ps1""" '%25cd%25') REM Remove unnecessary files from Release versions IF %25buildenv: Portable=%25==Release ( rmdir /s /q app.publish del /q *.pdb *.publish *.xml *.backup *.log *vshost* *.tmp -) +) + +REM Package ZIP if building Release Portable +IF %25buildenv: =%25==ReleasePortable ("$(SolutionDir)build-relport.cmd") true