From 3cf9accefc0b6a8f63217be7ccfd09a86ca80cf0 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Fri, 20 Aug 2021 11:54:24 +1000 Subject: [PATCH] Build Files --- src/.gitignore | 6 +- src/ARKServerManager/DeployBetaToGithub.cmd | 2 + src/ARKServerManager/DeployToGithub.cmd | 2 + src/ARKServerManager/Installer.iss | 54 +++++++ .../MakeLatestBetaVersionGithub.ps1 | 103 +++++++++++++ .../MakeLatestVersionGithub.ps1 | 137 ++++++++++++++++++ src/ConanServerManager/DeployBetaToGithub.cmd | 2 + src/ConanServerManager/DeployToGithub.cmd | 2 + src/ConanServerManager/Installer.iss | 54 +++++++ .../MakeLatestBetaVersionGithub.ps1 | 103 +++++++++++++ .../MakeLatestVersionGithub.ps1 | 137 ++++++++++++++++++ 11 files changed, 599 insertions(+), 3 deletions(-) create mode 100644 src/ARKServerManager/DeployBetaToGithub.cmd create mode 100644 src/ARKServerManager/DeployToGithub.cmd create mode 100644 src/ARKServerManager/Installer.iss create mode 100644 src/ARKServerManager/MakeLatestBetaVersionGithub.ps1 create mode 100644 src/ARKServerManager/MakeLatestVersionGithub.ps1 create mode 100644 src/ConanServerManager/DeployBetaToGithub.cmd create mode 100644 src/ConanServerManager/DeployToGithub.cmd create mode 100644 src/ConanServerManager/Installer.iss create mode 100644 src/ConanServerManager/MakeLatestBetaVersionGithub.ps1 create mode 100644 src/ConanServerManager/MakeLatestVersionGithub.ps1 diff --git a/src/.gitignore b/src/.gitignore index ecad615e..caeecf03 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -350,6 +350,6 @@ MigrationBackup/ .ionide/ # custom files -Deploy*Github.cmd -Installer.* -MakeLatest*.ps1 +#Deploy*Github.cmd +Installer.txt +#MakeLatest*.ps1 diff --git a/src/ARKServerManager/DeployBetaToGithub.cmd b/src/ARKServerManager/DeployBetaToGithub.cmd new file mode 100644 index 00000000..3033a56f --- /dev/null +++ b/src/ARKServerManager/DeployBetaToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestBetaVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/ARKServerManager/DeployToGithub.cmd b/src/ARKServerManager/DeployToGithub.cmd new file mode 100644 index 00000000..dd24efae --- /dev/null +++ b/src/ARKServerManager/DeployToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/ARKServerManager/Installer.iss b/src/ARKServerManager/Installer.iss new file mode 100644 index 00000000..ce3d5947 --- /dev/null +++ b/src/ARKServerManager/Installer.iss @@ -0,0 +1,54 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! +#define rootPath "D:\GitHub\ServerManagers\src\ARKServerManager" +#include "D:\GitHub\ServerManagers\src\ARKServerManager\Installer.txt" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{8CF4109C-917A-4F81-A189-164E4DF22C7C} +AppName=Ark Server Manager +AppVersion={#AppVer} +AppPublisher=Open Source Server Managers +AppPublisherURL=http://arkservermanager.freeforums.net/ +AppSupportURL=http://arkservermanager.freeforums.net/board/3/tech-support-bug-reports +AppUpdatesURL=http://arkservermanager.freeforums.net/thread/5193/downloads +DefaultDirName={pf}\ArkServerManager +DisableProgramGroupPage=yes +SetupIconFile={#rootPath}\Art\favicon.ico +VersionInfoVersion={#AppVerFull} + +ArchitecturesAllowed=x86 x64 ia64 +ArchitecturesInstallIn64BitMode=x64 ia64 + +Compression=lzma +SolidCompression=yes + +UninstallDisplayName=Ark Server Manager +UninstallDisplayIcon={app}\ARK Server Manager.exe + +SourceDir={#rootPath}\publish\Application Files\ARK Server Manager_{#AppVerPath} +OutputDir={#rootPath}\publish\ +OutputBaseFilename=ArkServerManager_{#AppVer} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 + +[Files] +Source: "ARK Server Manager.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{commonprograms}\ArkServerManager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager" +Name: "{commondesktop}\ArkServerManager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ArkServerManager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager"; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\ARK Server Manager.exe"; Description: "{cm:LaunchProgram,Ark Server Manager}"; Flags: nowait postinstall skipifsilent unchecked + diff --git a/src/ARKServerManager/MakeLatestBetaVersionGithub.ps1 b/src/ARKServerManager/MakeLatestBetaVersionGithub.ps1 new file mode 100644 index 00000000..c690594e --- /dev/null +++ b/src/ARKServerManager/MakeLatestBetaVersionGithub.ps1 @@ -0,0 +1,103 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\ARKServerManager", + + [Parameter()] + [string]$publishDir = "publish", + + [Parameter()] + [string]$srcXmlFilename = "ARK Server Manager.application", + + [Parameter()] + [string]$destLatestFilename = "latestbeta.txt", + + [Parameter()] + [string]$filenamePrefix = "Ark Server Manager_", + + [Parameter()] + [string]$feedFilename = "VersionFeedBeta.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\ASM\beta" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion() +{ + $xmlFile = "$($rootPath)\$($publishDir)\$($srcXmlFilename)" + $xml = [xml](Get-Content $xmlFile) + $version = $xml.assembly.assemblyIdentity | Select version + return $version.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +$publishPath = "$($rootPath)\$($publishDir)" +$txtDestFile = "$($publishPath)\$($destLatestFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" +$filenamePrefixStripped = $filenamePrefix.Replace(' ', '') + +$AppVersion = Get-LatestVersion +$AppVersionShort = $AppVersion +$AppVersionShort | Set-Content "$($txtDestFile)" +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishSrcDir = "$($publishPath)\Application Files\$($filenamePrefix)$($versionWithUnderscores)" +Remove-Item -Path "$($publishSrcDir)\$($srcXmlFilename)" -ErrorAction Ignore + +#copy the server manager updater (exe) and prefix with 'New' +Write-Host "Copying the server manager updater (exe) and prefix with 'New'" +Copy-Item -Path "$($publishSrcDir)\ServerManagerUpdater.exe" -Destination "$($publishSrcDir)\NewServerManagerUpdater.exe" + +#sign the executable files +Sign-Application $publishSrcDir "*.exe" + +$zipDestFileName = "$($filenamePrefixStripped)$($AppVersionShort).zip" +$zipDestFile = "$($publishPath)\$($zipDestFileName)" +Create-Zip $publishSrcDir $zipDestFile + +#delete the copied server manager updater File +Remove-Item -Path "$($publishSrcDir)\NewServerManagerUpdater.exe" -ErrorAction Ignore + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" diff --git a/src/ARKServerManager/MakeLatestVersionGithub.ps1 b/src/ARKServerManager/MakeLatestVersionGithub.ps1 new file mode 100644 index 00000000..80049959 --- /dev/null +++ b/src/ARKServerManager/MakeLatestVersionGithub.ps1 @@ -0,0 +1,137 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\ARKServerManager", + + [Parameter()] + [string]$publishDir = "publish", + + [Parameter()] + [string]$srcXmlFilename = "ARK Server Manager.application", + + [Parameter()] + [string]$destLatestFilename = "latest.txt", + + [Parameter()] + [string]$filenamePrefix = "Ark Server Manager_", + + [Parameter()] + [string]$feedFilename = "VersionFeed.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$installerTool = "C:\Program Files (x86)\Inno Setup 5\ISCC.exe", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\ASM" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion() +{ + $xmlFile = "$($rootPath)\$($publishDir)\$($srcXmlFilename)" + $xml = [xml](Get-Content $xmlFile) + $version = $xml.assembly.assemblyIdentity | Select version + return $version.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +function Create-Installer() +{ + if(Test-Path $installerTool) + { + if(($installScriptFile -ne "") -and ($installTextFile -ne "")) + { + $installTextFileContent = @" +#define AppVer "$($AppVersionShort)" +#define AppVerFull "$($AppVersion)" +#define AppVerPath "$($versionWithUnderscores)" +"@ + $installTextFileContent | Out-File -LiteralPath:$installTextFile -Force -Encoding ascii + + Write-Host "Creating installer $($installerFile)" + & "$installerTool" "$installScriptFile" + } + } +} + +$publishPath = "$($rootPath)\$($publishDir)" +$txtDestFile = "$($publishPath)\$($destLatestFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" +$installTextFile = "$($rootPath)\Installer.txt" +$installScriptFile = "$($rootPath)\Installer.iss" +$filenamePrefixStripped = $filenamePrefix.Replace(' ', '') + +$AppVersion = Get-LatestVersion +$AppVersionShort = $AppVersion.Substring(0, $AppVersion.LastIndexOf('.')) +$AppVersionShort | Set-Content "$($txtDestFile)" +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishSrcDir = "$($publishPath)\Application Files\$($filenamePrefix)$($versionWithUnderscores)" +Remove-Item -Path "$($publishSrcDir)\$($srcXmlFilename)" -ErrorAction Ignore + +#copy the server manager updater (exe) and prefix with 'New' +Write-Host "Copying the server manager updater (exe) and prefix with 'New'" +Copy-Item -Path "$($publishSrcDir)\ServerManagerUpdater.exe" -Destination "$($publishSrcDir)\NewServerManagerUpdater.exe" + +#sign the executable files +Sign-Application $publishSrcDir "*.exe" + +$zipDestFileName = "$($filenamePrefixStripped)$($AppVersionShort).zip" +$zipDestFile = "$($publishPath)\$($zipDestFileName)" +Create-Zip $publishSrcDir $zipDestFile + +#delete the copied server manager updater File - do not want to include in the installer +Remove-Item -Path "$($publishSrcDir)\NewServerManagerUpdater.exe" -ErrorAction Ignore + +$installerFileName = "$($filenamePrefixStripped)$($AppVersionShort).exe" +$installerFile = "$($publishPath)\$($installerFileName)" +Create-Installer + +#sign the installer file +Sign-Application $publishPath $installerFileName + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination $githubRoot +Copy-Item -Path "$installerFile" -Destination $githubRoot +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" +Copy-Item -Path "$installerFile" -Destination "$githubRoot\latest.exe" diff --git a/src/ConanServerManager/DeployBetaToGithub.cmd b/src/ConanServerManager/DeployBetaToGithub.cmd new file mode 100644 index 00000000..3033a56f --- /dev/null +++ b/src/ConanServerManager/DeployBetaToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestBetaVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/ConanServerManager/DeployToGithub.cmd b/src/ConanServerManager/DeployToGithub.cmd new file mode 100644 index 00000000..dd24efae --- /dev/null +++ b/src/ConanServerManager/DeployToGithub.cmd @@ -0,0 +1,2 @@ +powershell -ExecutionPolicy Bypass -File MakeLatestVersionGithub.ps1 +PAUSE \ No newline at end of file diff --git a/src/ConanServerManager/Installer.iss b/src/ConanServerManager/Installer.iss new file mode 100644 index 00000000..484893c4 --- /dev/null +++ b/src/ConanServerManager/Installer.iss @@ -0,0 +1,54 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! +#define rootPath "D:\GitHub\ServerManagers\src\ConanServerManager" +#include "D:\GitHub\ServerManagers\src\ConanServerManager\Installer.txt" + +[Setup] +; NOTD: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{783D6AFF-E78C-44D5-B9E2-764D7C62C7FD} +AppName=Conan Server Manager +AppVersion={#AppVer} +AppPublisher=Open Source Server Managers +AppPublisherURL=http://servermanagers.freeforums.net +AppSupportURL=http://servermanagers.freeforums.net/board/39/tech-support-bug-reports +AppUpdatesURL=http://servermanagers.freeforums.net/thread/36/downloads +DefaultDirName={pf}\ConanServerManager +DisableProgramGroupPage=yes +SetupIconFile={#rootPath}\Art\favicon.ico +VersionInfoVersion={#AppVerFull} + +ArchitecturesAllowed=x86 x64 ia64 +ArchitecturesInstallIn64BitMode=x64 ia64 + +Compression=lzma +SolidCompression=yes + +UninstallDisplayName=Conan Server Manager +UninstallDisplayIcon={app}\ConanServerManager.exe + +SourceDir={#rootPath}\publish\Application Files\ConanServerManager_{#AppVerPath} +OutputDir={#rootPath}\publish\ +OutputBaseFilename=ConanServerManager_{#AppVer} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 + +[Files] +Source: "ConanServerManager.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{commonprograms}\ConanServerManager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager" +Name: "{commondesktop}\ConanServerManager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ConanServerManager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager"; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\ConanServerManager.exe"; Description: "{cm:LaunchProgram,Conan Server Manager}"; Flags: nowait postinstall skipifsilent unchecked + diff --git a/src/ConanServerManager/MakeLatestBetaVersionGithub.ps1 b/src/ConanServerManager/MakeLatestBetaVersionGithub.ps1 new file mode 100644 index 00000000..e7248421 --- /dev/null +++ b/src/ConanServerManager/MakeLatestBetaVersionGithub.ps1 @@ -0,0 +1,103 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\ConanServerManager", + + [Parameter()] + [string]$publishDir = "publish", + + [Parameter()] + [string]$srcXmlFilename = "ConanServerManager.application", + + [Parameter()] + [string]$destLatestFilename = "latestbeta.txt", + + [Parameter()] + [string]$filenamePrefix = "ConanServerManager_", + + [Parameter()] + [string]$feedFilename = "VersionFeedBeta.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\CSM\beta" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion() +{ + $xmlFile = "$($rootPath)\$($publishDir)\$($srcXmlFilename)" + $xml = [xml](Get-Content $xmlFile) + $version = $xml.assembly.assemblyIdentity | Select version + return $version.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +$publishPath = "$($rootPath)\$($publishDir)" +$txtDestFile = "$($publishPath)\$($destLatestFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" +$filenamePrefixStripped = $filenamePrefix.Replace(' ', '') + +$AppVersion = Get-LatestVersion +$AppVersionShort = $AppVersion +$AppVersionShort | Set-Content "$($txtDestFile)" +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishSrcDir = "$($publishPath)\Application Files\$($filenamePrefix)$($versionWithUnderscores)" +Remove-Item -Path "$($publishSrcDir)\$($srcXmlFilename)" -ErrorAction Ignore + +#copy the server manager updater (exe) and prefix with 'New' +Write-Host "Copying the server manager updater (exe) and prefix with 'New'" +Copy-Item -Path "$($publishSrcDir)\ServerManagerUpdater.exe" -Destination "$($publishSrcDir)\NewServerManagerUpdater.exe" + +#sign the executable files +Sign-Application $publishSrcDir "*.exe" + +$zipDestFileName = "$($filenamePrefixStripped)$($AppVersionShort).zip" +$zipDestFile = "$($publishPath)\$($zipDestFileName)" +Create-Zip $publishSrcDir $zipDestFile + +#delete the copied server manager updater File +Remove-Item -Path "$($publishSrcDir)\NewServerManagerUpdater.exe" -ErrorAction Ignore + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" diff --git a/src/ConanServerManager/MakeLatestVersionGithub.ps1 b/src/ConanServerManager/MakeLatestVersionGithub.ps1 new file mode 100644 index 00000000..96cb37e3 --- /dev/null +++ b/src/ConanServerManager/MakeLatestVersionGithub.ps1 @@ -0,0 +1,137 @@ +Param +( + [Parameter()] + [string]$rootPath = "D:\GitHub\ServerManagers\src\ConanServerManager", + + [Parameter()] + [string]$publishDir = "publish", + + [Parameter()] + [string]$srcXmlFilename = "ConanServerManager.application", + + [Parameter()] + [string]$destLatestFilename = "latest.txt", + + [Parameter()] + [string]$filenamePrefix = "ConanServerManager_", + + [Parameter()] + [string]$feedFilename = "VersionFeed.xml", + + [Parameter()] + [string]$signTool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe", + + [Parameter()] + [string]$signNFlag = "${env:SIGN_NFLAG}", + + [Parameter()] + [string]$signTFlag = "http://timestamp.digicert.com", + + [Parameter()] + [string]$installerTool = "C:\Program Files (x86)\Inno Setup 5\ISCC.exe", + + [Parameter()] + [string]$githubRoot = "D:\GitHub\ServerManagers\CSM" +) + +[string] $AppVersion = "" +[string] $AppVersionShort = "" + +function Get-LatestVersion() +{ + $xmlFile = "$($rootPath)\$($publishDir)\$($srcXmlFilename)" + $xml = [xml](Get-Content $xmlFile) + $version = $xml.assembly.assemblyIdentity | Select version + return $version.version; +} + +function Sign-Application ( $sourcedir , $signFile ) +{ + if(Test-Path $signTool) + { + if(($signFile -ne "") -and ($signNFlag -ne "") -and ($signTFlag -ne "")) + { + Write-Host "Signing $($signFile)" + & $signTool sign /n "$($signNFlag)" /t $signTFlag "$($sourcedir)\$($signFile)" + } + } +} + +function Create-Zip( $sourcePath , $zipFile ) +{ + if(Test-Path $zipFile) + { + Remove-Item -LiteralPath:$zipFile -Force + } + Add-Type -Assembly System.IO.Compression.FileSystem + Write-Host "Zipping $($sourcePath) into $($zipFile)" + $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipFile, $compressionLevel, $false) +} + +function Create-Installer() +{ + if(Test-Path $installerTool) + { + if(($installScriptFile -ne "") -and ($installTextFile -ne "")) + { + $installTextFileContent = @" +#define AppVer "$($AppVersionShort)" +#define AppVerFull "$($AppVersion)" +#define AppVerPath "$($versionWithUnderscores)" +"@ + $installTextFileContent | Out-File -LiteralPath:$installTextFile -Force -Encoding ascii + + Write-Host "Creating installer $($installerFile)" + & "$installerTool" "$installScriptFile" + } + } +} + +$publishPath = "$($rootPath)\$($publishDir)" +$txtDestFile = "$($publishPath)\$($destLatestFilename)" +$feedFile = "$($rootPath)\$($feedFilename)" +$languageFile = "$($rootPath)\Globalization\en-US\en-US.xaml" +$installTextFile = "$($rootPath)\Installer.txt" +$installScriptFile = "$($rootPath)\Installer.iss" +$filenamePrefixStripped = $filenamePrefix.Replace(' ', '') + +$AppVersion = Get-LatestVersion +$AppVersionShort = $AppVersion.Substring(0, $AppVersion.LastIndexOf('.')) +$AppVersionShort | Set-Content "$($txtDestFile)" +Write-Host "LatestVersion $($AppVersionShort) ($($AppVersion))" + +$versionWithUnderscores = $AppVersion.Replace('.', '_') +$publishSrcDir = "$($publishPath)\Application Files\$($filenamePrefix)$($versionWithUnderscores)" +Remove-Item -Path "$($publishSrcDir)\$($srcXmlFilename)" -ErrorAction Ignore + +#copy the server manager updater (exe) and prefix with 'New' +Write-Host "Copying the server manager updater (exe) and prefix with 'New'" +Copy-Item -Path "$($publishSrcDir)\ServerManagerUpdater.exe" -Destination "$($publishSrcDir)\NewServerManagerUpdater.exe" + +#sign the executable files +Sign-Application $publishSrcDir "*.exe" + +$zipDestFileName = "$($filenamePrefixStripped)$($AppVersionShort).zip" +$zipDestFile = "$($publishPath)\$($zipDestFileName)" +Create-Zip $publishSrcDir $zipDestFile + +#delete the copied server manager updater File - do not want to include in the installer +Remove-Item -Path "$($publishSrcDir)\NewServerManagerUpdater.exe" -ErrorAction Ignore + +$installerFileName = "$($filenamePrefixStripped)$($AppVersionShort).exe" +$installerFile = "$($publishPath)\$($installerFileName)" +Create-Installer + +#sign the installer file +Sign-Application $publishPath $installerFileName + +# copy the files to the GITHUB folder +Write-Host "Copying files to the github folder" +Copy-Item -Path "$feedFile" -Destination "$githubRoot\VersionFeed.xml" +Copy-Item -Path "$languageFile" -Destination $githubRoot +Copy-Item -Path "$txtDestFile" -Destination "$githubRoot\latest.txt" +Copy-Item -Path "$zipDestFile" -Destination $githubRoot +Copy-Item -Path "$installerFile" -Destination $githubRoot +Copy-Item -Path "$zipDestFile" -Destination "$githubRoot\latest.zip" +Copy-Item -Path "$installerFile" -Destination "$githubRoot\latest.exe"