From 375607da9044779546767a4d1b590c8e6ef5e1d6 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Thu, 22 Dec 2022 21:04:21 +1000 Subject: [PATCH] Update azure-pipelines.yml for Azure Pipelines --- .azure/pipelines/azure-pipelines.yml | 71 +++++++++++++++++++--------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/.azure/pipelines/azure-pipelines.yml b/.azure/pipelines/azure-pipelines.yml index cbe03611..a9a8e4ca 100644 --- a/.azure/pipelines/azure-pipelines.yml +++ b/.azure/pipelines/azure-pipelines.yml @@ -178,6 +178,32 @@ stages: flattenFolders: true preserveTimestamp: true + - task: PowerShell@2 + displayName: Cleanup Published Files + env: + BUILD_BUILDNUMBER: $(Build.BuildNumber) + BUILD_ARTIFACTSTAGINGDIRECTORY: $(Build.ArtifactStagingDirectory) + inputs: + targetType: 'inline' + script: | + $appVersion = $env:BUILD_BUILDNUMBER + $appVersionWithUnderscores = $appVersion.Replace('.', '_') + + # Remove unwanted files + Remove-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/*.application" -Force -ErrorAction Ignore + Remove-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/*.exe" -Force -ErrorAction Ignore + + # Rename application files Folder + $applicationFolders = Get-ChildItem -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Application Files" -Filter "*_$appVersionWithUnderscores" -Directory -Name + $applicationFolder = $applicationFolders.Where({$_.Replace(' ', '') -eq "$(ApplicationName)_$appVersionWithUnderscores"}) + if ($applicationFolder.Count -ne 1) { + throw "Could not find the application folder ($(ApplicationName)_$appVersionWithUnderscores)" + } + $applicationFolderName = $applicationFolder[0] + + Rename-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Application Files\$applicationFolderName" -NewName "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\Application Files\$($ApplicationName)_$appVersionWithUnderscores" -Force + pwsh: true + - task: PowerShell@2 displayName: Create Latest Version Files env: @@ -193,8 +219,8 @@ stages: $versionFile = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/latest.txt" $AppVersionShort | Set-Content "$versionFile" - $versionFileBeta = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/latestBeta.txt" - $AppVersion | Set-Content "$versionFileBeta" + $versionFile = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/latestBeta.txt" + $AppVersion | Set-Content "$versionFile" pwsh: true - task: PowerShell@2 @@ -219,8 +245,9 @@ stages: #define AppVerPath "$appVersionWithUnderscores" #define RootPath "$env:BUILD_ARTIFACTSTAGINGDIRECTORY" "@ - $installTextFileContent | Out-File -LiteralPath:$installTextFile -Force -Encoding ascii - + #$installTextFileContent | Out-File -LiteralPath:$installTextFile -Force -Encoding ascii + $installTextFileContent | Set-Content "$installTextFile" -Encoding Ascii -Force + & "$env:AGENTCAPABILITIES_USER_INNOSETUP" "$installScriptFile" pwsh: true @@ -236,16 +263,16 @@ stages: $appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.')) $appVersionWithUnderscores = $appVersion.Replace('.', '_') - $fileExtension = '.application' - $applicationFiles = Get-ChildItem -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Filter "*$fileExtension" -File -Name - $applicationFile = $applicationFiles.Where({$_.Replace(' ', '') -eq "$(ApplicationName)$fileExtension"}) - if ($applicationFile.Count -ne 1) { - throw "Could not find the application file ($(ApplicationName)$fileExtension)" - } - $applicationFileName = [System.IO.Path]::GetFileNameWithoutExtension($applicationFile[0]) - $applicationFolder = "$($applicationFileName)_$($appVersionWithUnderscores)" + #$fileExtension = '.application' + #$applicationFiles = Get-ChildItem -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Filter "*$fileExtension" -File -Name + #$applicationFile = $applicationFiles.Where({$_.Replace(' ', '') -eq "$(ApplicationName)$fileExtension"}) + #if ($applicationFile.Count -ne 1) { + # throw "Could not find the application file ($(ApplicationName)$fileExtension)" + #} + #$applicationFileName = [System.IO.Path]::GetFileNameWithoutExtension($applicationFile[0]) + $applicationFolderName = "$(ApplicationName)_$($appVersionWithUnderscores)" - $sourcePath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/Application Files/$applicationFolder" + $sourcePath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/Application Files/$applicationFolderName" Copy-Item -Path "$sourcePath\ServerManagerUpdater.exe" -Destination "$sourcePath\NewServerManagerUpdater.exe" -Force pwsh: true @@ -261,16 +288,16 @@ stages: $appVersionShort = $appVersion.Substring(0, $appVersion.LastIndexOf('.')) $appVersionWithUnderscores = $appVersion.Replace('.', '_') - $fileExtension = '.application' - $applicationFiles = Get-ChildItem -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Filter "*$fileExtension" -File -Name - $applicationFile = $applicationFiles.Where({$_.Replace(' ', '') -eq "$(ApplicationName)$fileExtension"}) - if ($applicationFile.Count -ne 1) { - throw "Could not find the application file ($(ApplicationName)$fileExtension)" - } - $applicationFileName = [System.IO.Path]::GetFileNameWithoutExtension($applicationFile[0]) - $applicationFolder = "$($applicationFileName)_$($appVersionWithUnderscores)" + #$fileExtension = '.application' + #$applicationFiles = Get-ChildItem -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Filter "*$fileExtension" -File -Name + #$applicationFile = $applicationFiles.Where({$_.Replace(' ', '') -eq "$(ApplicationName)$fileExtension"}) + #if ($applicationFile.Count -ne 1) { + # throw "Could not find the application file ($(ApplicationName)$fileExtension)" + #} + #$applicationFileName = [System.IO.Path]::GetFileNameWithoutExtension($applicationFile[0]) + $applicationFolderName = "$(ApplicationName)_$($appVersionWithUnderscores)" - $sourcePath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/Application Files/$applicationFolder" + $sourcePath = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/Application Files/$applicationFolderName" $zipFile1 = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/latest.zip" $zipFile2 = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$(ApplicationName)_$($appVersionShort).zip"