From 321fd1162bed9d1895dd6aa1dcfb0351c7385b67 Mon Sep 17 00:00:00 2001 From: BlueBlock Date: Thu, 16 Mar 2023 11:08:27 -0400 Subject: [PATCH] appveyor build automation bulk of the changes for appveyor automation --- Tools/create_upg_chk_files.ps1 | 47 ++++++++-------- Tools/find_vstool.ps1 | 3 +- Tools/github_functions.ps1 | 9 +-- Tools/postbuild_installer.ps1 | 6 +- ...d_mremoteng.ps1 => postbuild_portable.ps1} | 12 ++-- Tools/rename_and_copy_installer.ps1 | 16 ++++-- Tools/sign_binaries.ps1 | 11 ++-- Tools/signfiles.ps1 | 4 +- Tools/tidy_files_for_release.ps1 | 17 +++--- ...e_and_upload_website_release_json_file.ps1 | 55 ++++++++++--------- Tools/validate_microsoft_tool.ps1 | 10 +++- Tools/verify_LargeAddressAware.ps1 | 8 ++- Tools/verify_binary_signatures.ps1 | 13 +++-- Tools/zip_files.ps1 | 43 ++++++++++----- mRemoteNG/mRemoteNG.csproj | 2 +- 15 files changed, 151 insertions(+), 105 deletions(-) rename Tools/{postbuild_mremoteng.ps1 => postbuild_portable.ps1} (79%) diff --git a/Tools/create_upg_chk_files.ps1 b/Tools/create_upg_chk_files.ps1 index f063b589..2c1b3fdc 100644 --- a/Tools/create_upg_chk_files.ps1 +++ b/Tools/create_upg_chk_files.ps1 @@ -97,69 +97,72 @@ function Resolve-UpdateCheckFileName { Write-Output $fileName } -Write-Output "===== Begin create_upg_chk_files.ps1 =====" +Write-Output "" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" # determine update channel if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") { - write-host "UpdateChannel = Nightly" + Write-Output "UpdateChannel = Nightly" $UpdateChannel = "Nightly" $ModifiedTagName = "$PreTagName-$TagName-NB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") { - write-host "UpdateChannel = Preview" + Write-Output "UpdateChannel = Preview" $UpdateChannel = "Preview" $ModifiedTagName = "v$TagName-PB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") { - write-host "UpdateChannel = Stable" + Write-Output "UpdateChannel = Stable" $UpdateChannel = "Stable" $ModifiedTagName = "v" + $TagName.Split("-")[0] } else { $UpdateChannel = "" } -$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore +#$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore +$ReleaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve -if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $WebsiteTargetOwner -ne "" -and $WebsiteTargetRepository -ne "" ) { +if ($UpdateChannel -ne "" -and $ReleaseFolder -ne "" -and $WebsiteTargetOwner -and $WebsiteTargetRepository) { - $releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve - $msiFile = Get-ChildItem -Path "$buildFolder\*.msi" | Sort-Object LastWriteTime | Select-Object -last 1 + $msiFile = Get-ChildItem -Path "$ReleaseFolder\*.msi" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1 if (![string]::IsNullOrEmpty($msiFile)) { $msiUpdateContents = New-MsiUpdateFileContent -MsiFile $msiFile -TagName $ModifiedTagName $msiUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Normal Write-Output "`n`nMSI Update Check File Contents ($msiUpdateFileName)`n------------------------------" - Tee-Object -InputObject $msiUpdateContents -FilePath "$releaseFolder\$msiUpdateFileName" - write-host "msiUpdateFileName $releaseFolder\$msiUpdateFileName" + Tee-Object -InputObject $msiUpdateContents -FilePath "$ReleaseFolder\$msiUpdateFileName" # commit msi update txt file if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") { - if ((Test-Path -Path "$releaseFolder\$msiUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) { - Write-Output "Publish $msiUpdateFileName to $WebsiteTargetRepository" - $update_file_content_string = Get-Content "$releaseFolder\$msiUpdateFileName" | Out-String + if ((Test-Path -Path "$ReleaseFolder\$msiUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) { + Write-Output "Publish Update File $msiUpdateFileName to $WebsiteTargetRepository" + $update_file_content_string = Get-Content "$ReleaseFolder\$msiUpdateFileName" | Out-String Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path $msiUpdateFileName -CommitMessage "Build $ModifiedTagName" -Content $update_file_content_string -BranchName main + } else { + Write-Warning "WARNING: Update file does not exist: $ReleaseFolder\$msiUpdateFileName" } } } # build zip update file - $releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve - $zipFile = Get-ChildItem -Path "$releaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1 + $zipFile = Get-ChildItem -Path "$ReleaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1 if (![string]::IsNullOrEmpty($zipFile)) { $zipUpdateContents = New-ZipUpdateFileContent -ZipFile $zipFile -TagName $ModifiedTagName $zipUpdateFileName = Resolve-UpdateCheckFileName -UpdateChannel $UpdateChannel -Type Portable Write-Output "`n`nZip Update Check File Contents ($zipUpdateFileName)`n------------------------------" - Tee-Object -InputObject $zipUpdateContents -FilePath "$releaseFolder\$zipUpdateFileName" - write-host "zipUpdateFileName $releaseFolder\$zipUpdateFileName" + Tee-Object -InputObject $zipUpdateContents -FilePath "$ReleaseFolder\$zipUpdateFileName" # commit zip update txt file if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") { - if ((Test-Path -Path "$releaseFolder\$zipUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) { - Write-Output "Publish $zipUpdateFileName to $WebsiteTargetRepository" - $update_file_content_string = Get-Content "$releaseFolder\$zipUpdateFileName" | Out-String + if ((Test-Path -Path "$ReleaseFolder\$zipUpdateFileName") -and (-not [string]::IsNullOrEmpty($WebsiteTargetRepository))) { + Write-Output "Publish Update File $zipUpdateFileName to $WebsiteTargetRepository" + $update_file_content_string = Get-Content "$ReleaseFolder\$zipUpdateFileName" | Out-String Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path $zipUpdateFileName -CommitMessage "Build $ModifiedTagName" -Content $update_file_content_string -BranchName main + } else { + Write-Warning "WARNING: Update file does not exist: $ReleaseFolder\$zipUpdateFileName" } } } } else { - write-host "BuildFolder not found" + Write-Output "ReleaseFolder not found" } -Write-Output "End create_upg_chk_files.ps1" +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/Tools/find_vstool.ps1 b/Tools/find_vstool.ps1 index f60c1fa6..bc6d1333 100644 --- a/Tools/find_vstool.ps1 +++ b/Tools/find_vstool.ps1 @@ -23,10 +23,9 @@ function EditBinCertificateIsValid() { "97221B97098F37A135DCC212E2B41E452BCE51F2" ) $file_signature = Get-AuthenticodeSignature -FilePath $Path - write-host "Path: $Path" - Write-Host "file_signature.SignerCertificate.Thumbprint: $($file_signature.SignerCertificate.Thumbprint)" if (($file_signature.Status -ne "Valid") -or ($valid_microsoft_cert_thumbprints -notcontains $file_signature.SignerCertificate.Thumbprint)) { Write-Warning "Could not validate the signature of $Path" + Write-Output "file_signature.SignerCertificate.Thumbprint: $($file_signature.SignerCertificate.Thumbprint)" return $false } else { return $true diff --git a/Tools/github_functions.ps1 b/Tools/github_functions.ps1 index 3d493f28..d406b5b1 100644 --- a/Tools/github_functions.ps1 +++ b/Tools/github_functions.ps1 @@ -2,9 +2,10 @@ $githubUrl = 'https://api.github.com' # GitHub doesn't support the default powershell protocol (TLS 1.0) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -#$ConfigurationName = $ConfigurationName.Trim() -if (![string]::IsNullOrEmpty($env:APPVEYOR_REPO_NAME)) { - $CURRENT_GITHUB_USER = $env:APPVEYOR_REPO_NAME.Split("/")[0] +$IsAppVeyor = !([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) + +if ($IsAppVeyor) { + #$CURRENT_GITHUB_USER = $env:APPVEYOR_REPO_NAME.Split("/")[0] Install-Module -Name PowerShellForGitHub -Scope CurrentUser Set-GitHubConfiguration -DisableTelemetry $PSDefaultParameterValues["*-GitHub*:AccessToken"] = "$env:ACCESS_TOKEN" @@ -248,4 +249,4 @@ function New-GitHubReleaseRequestBody { $json_body = ConvertTo-Json -InputObject $body_params -Compress Write-Output $json_body -} \ No newline at end of file +} diff --git a/Tools/postbuild_installer.ps1 b/Tools/postbuild_installer.ps1 index 656de53c..cfed94c5 100644 --- a/Tools/postbuild_installer.ps1 +++ b/Tools/postbuild_installer.ps1 @@ -27,6 +27,7 @@ param ( . "$PSScriptRoot\github_functions.ps1" +Write-Output "" Write-Output "+===========================================================================================+" Write-Output "| Beginning mRemoteNG Installer Post Build |" Write-Output "+===========================================================================================+" @@ -46,11 +47,12 @@ Format-Table -AutoSize -Wrap -InputObject @{ & "$PSScriptRoot\rename_and_copy_installer.ps1" -SolutionDir $SolutionDir -BuildConfiguration $ConfigurationName.Trim() -if ( ![string]::IsNullOrEmpty($env:MAIN_REPOSITORY) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_OWNER) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_REPOSITORY) ) { +if ( ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_OWNER) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_REPOSITORY) ) { & "$PSScriptRoot\create_upg_chk_files.ps1" -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME - & "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -MainRepository $env:MAIN_REPOSITORY -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME + & "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME } Write-Output "End mRemoteNG Installer Post Build" +Write-Output "" diff --git a/Tools/postbuild_mremoteng.ps1 b/Tools/postbuild_portable.ps1 similarity index 79% rename from Tools/postbuild_mremoteng.ps1 rename to Tools/postbuild_portable.ps1 index 2e479f7e..ee07771d 100644 --- a/Tools/postbuild_mremoteng.ps1 +++ b/Tools/postbuild_portable.ps1 @@ -27,8 +27,9 @@ param ( . "$PSScriptRoot\github_functions.ps1" +Write-Output "" Write-Output "+===========================================================================================+" -Write-Output "| Beginning mRemoteNG Post Build |" +Write-Output "| Beginning mRemoteNG Portable Post Build |" Write-Output "+===========================================================================================+" Format-Table -AutoSize -Wrap -InputObject @{ "SolutionDir" = $SolutionDir @@ -57,7 +58,7 @@ Format-Table -AutoSize -Wrap -InputObject @{ # Currently targeting x64, shouldn't need to manually set LargeAddressAware... #& "$PSScriptRoot\set_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName -& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName +#& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName & "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName @@ -67,12 +68,13 @@ Format-Table -AutoSize -Wrap -InputObject @{ & "$PSScriptRoot\zip_files.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -ConfigurationName $ConfigurationName -if ( ![string]::IsNullOrEmpty($env:MAIN_REPOSITORY) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_OWNER) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_REPOSITORY) ) { +if ( ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_OWNER) -and ![string]::IsNullOrEmpty($env:WEBSITE_TARGET_REPOSITORY) ) { & "$PSScriptRoot\create_upg_chk_files.ps1" -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME - & "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -MainRepository $env:MAIN_REPOSITORY -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME + & "$PSScriptRoot\update_and_upload_website_release_json_file.ps1" -WebsiteTargetOwner $env:WEBSITE_TARGET_OWNER -WebsiteTargetRepository $env:WEBSITE_TARGET_REPOSITORY -PreTagName $env:NightlyBuildTagName -TagName $env:APPVEYOR_BUILD_VERSION -ProjectName $env:APPVEYOR_PROJECT_NAME } -Write-Output "End mRemoteNG Post Build" +Write-Output "End mRemoteNG Portable Post Build" +Write-Output "" diff --git a/Tools/rename_and_copy_installer.ps1 b/Tools/rename_and_copy_installer.ps1 index b77bbc69..d66250e2 100644 --- a/Tools/rename_and_copy_installer.ps1 +++ b/Tools/rename_and_copy_installer.ps1 @@ -5,6 +5,7 @@ $BuildConfiguration ) +Write-Output "" Write-Output "===== Begin rename_and_copy_installer.ps1 =====" $targetVersionedFile = "$SolutionDir\mRemoteNG\bin\x64\$BuildConfiguration\mRemoteNG.exe" @@ -15,19 +16,24 @@ $msiversion = $fileversion # determine update channel if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") { - write-host "UpdateChannel = Nightly" + Write-Output "UpdateChannel = Nightly" $msiversion = "$msiversion-NB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") { - write-host "UpdateChannel = Preview" + Write-Output "UpdateChannel = Preview" $msiversion = "$msiversion-PB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") { - write-host "UpdateChannel = Stable" + Write-Output "UpdateChannel = Stable" } else { } $srcMsi = $SolutionDir + "mRemoteNGInstaller\Installer\bin\x64\$BuildConfiguration\en-US\mRemoteNG-Installer*.msi" -$dstMsi = $SolutionDir + "mRemoteNG\bin\x64\$BuildConfiguration\mRemoteNG-Installer-" + $msiversion + ".msi" +$dstMsi = $SolutionDir + "Release\mRemoteNG-Installer-" + $msiversion + ".msi" +$srcSymbols = $SolutionDir + "mRemoteNGInstaller\Installer\bin\x64\$BuildConfiguration\en-US\mRemoteNG-Installer-Symbols*.zip" +$dstSymbols = $SolutionDir + "Release\mRemoteNG-Installer-Symbols-" + $msiversion + ".zip" -# Copy file +# Copy files Copy-Item $srcMsi -Destination $dstMsi -Force +Copy-Item $srcSymbols -Destination $dstSymbols -Force +Write-Output "End rename_and_copy_installer.ps1" +Write-Output "" diff --git a/Tools/sign_binaries.ps1 b/Tools/sign_binaries.ps1 index 3e1277ca..71c1434b 100644 --- a/Tools/sign_binaries.ps1 +++ b/Tools/sign_binaries.ps1 @@ -24,16 +24,17 @@ param ( $SolutionDir ) -Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) =====" - +Write-Output "" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" $timeserver = "http://timestamp.verisign.com/scripts/timstamp.dll" +$IsAppVeyor = !([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) # validate release versions and if the certificate value was passed if ($ConfigurationName -match "Release" -And ($CertificatePath)) { - if(-Not ([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) ) { + if($IsAppVeyor) { $CertificatePath = Join-Path -Path $SolutionDir -ChildPath $CertificatePath } @@ -77,7 +78,7 @@ if ($ConfigurationName -match "Release" -And ($CertificatePath)) { # Release certificate - if ($cert -ne $null) { + if ($null -ne $cert) { $cert.Dispose() } } else { @@ -85,4 +86,4 @@ if ($ConfigurationName -match "Release" -And ($CertificatePath)) { Write-Output "Config: $($ConfigurationName)`tCertPath: $($CertificatePath)" } -Write-Output "" \ No newline at end of file +Write-Output "" diff --git a/Tools/signfiles.ps1 b/Tools/signfiles.ps1 index 5b59cd1e..5ad3df45 100644 --- a/Tools/signfiles.ps1 +++ b/Tools/signfiles.ps1 @@ -28,4 +28,6 @@ Write-Output "Signable files count: $($signableFiles.Count)" foreach ($file in $signableFiles) { Set-AuthenticodeSignature -Certificate $cert -TimestampServer $timeserver -IncludeChain all -FilePath $file.FullName -} \ No newline at end of file +} + +Write-Output "" diff --git a/Tools/tidy_files_for_release.ps1 b/Tools/tidy_files_for_release.ps1 index fc8fdb65..7a200bb4 100644 --- a/Tools/tidy_files_for_release.ps1 +++ b/Tools/tidy_files_for_release.ps1 @@ -7,12 +7,12 @@ param ( [Parameter(Mandatory=$true)] $ConfigurationName ) + Write-Output "" -Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) =====" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" # Remove unnecessary files from Release versions -if ($ConfigurationName -match "Release") -{ +if ($ConfigurationName -match "Release") { $test = Join-Path -Path $TargetDir -ChildPath "app.publish" if (Test-Path $test -PathType Container) { @@ -29,19 +29,18 @@ if ($ConfigurationName -match "Release") ) -Exclude @( "mRemoteNG.VisualElementsManifest.xml" ) + if ($filesToDelete) { Write-Output "Unnecessary files are detected and will be removed" Remove-Item -Path $filesToDelete.FullName Write-Output $filesToDelete.FullName - } else - { + } else { Write-Output " No unnecessary files are detected" } -} -else -{ +} else { Write-Output "We will not remove anything - this is not a release build." } -Write-Output "" \ No newline at end of file +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/Tools/update_and_upload_website_release_json_file.ps1 b/Tools/update_and_upload_website_release_json_file.ps1 index e6237bfa..bf2d3ef6 100644 --- a/Tools/update_and_upload_website_release_json_file.ps1 +++ b/Tools/update_and_upload_website_release_json_file.ps1 @@ -1,9 +1,5 @@ #Requires -Version 4.0 param ( - [string] - [Parameter(Mandatory=$true)] - $MainRepository, - [string] [Parameter(Mandatory=$true)] $WebsiteTargetOwner, @@ -26,43 +22,45 @@ param ( ) -Write-Output "===== Begin update_and_upload_website_release_json_file.ps1 =====" +Write-Output "" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" +$MainRepository = $Env:APPVEYOR_REPO_NAME.Split("/\")[1] # determine update channel if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") { - write-host "UpdateChannel = Nightly" + Write-Output "UpdateChannel = Nightly" $UpdateChannel = "Nightly" $ModifiedTagName = "$PreTagName-$TagName-NB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") { - write-host "UpdateChannel = Preview" + Write-Output "UpdateChannel = Preview" $UpdateChannel = "Preview" $ModifiedTagName = "v$TagName-PB" } elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") { - write-host "UpdateChannel = Stable" + Write-Output "UpdateChannel = Stable" $UpdateChannel = "Stable" $ModifiedTagName = "v" + $TagName.Split("-")[0] } else { $UpdateChannel = "" } -$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore +#$buildFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\mRemoteNG\bin\x64\Release" -Resolve -ErrorAction Ignore +$ReleaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve -if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" -and $WebsiteTargetOwner -ne "" -and $WebsiteTargetRepository -ne "" ) { +if ($UpdateChannel -ne "" -and $ReleaseFolder -ne "" -and $MainRepository -ne "" -and $WebsiteTargetOwner -ne "" -and $WebsiteTargetRepository -ne "" ) { - $releaseFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\Release" -Resolve $published_at = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - #$websiteJsonReleaseFile = Join-Path -Path $PSScriptRoot -ChildPath "..\..\mRemoteNG.github.io\_data\releases.json" -Resolve - # get releases.json from github $releases_json = Get-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path _data\releases.json - ConvertFrom-Base64($releases_json.content) | Out-File -FilePath "$releaseFolder\releases.json" - $websiteJsonReleaseFile = Get-ChildItem -Path "$releaseFolder\releases.json" + ConvertFrom-Base64($releases_json.content) | Out-File -FilePath "$ReleaseFolder\releases.json" + $websiteJsonReleaseFile = Get-ChildItem -Path "$ReleaseFolder\releases.json" # installer - $msiFile = Get-ChildItem -Path "$buildFolder\*.msi" | Sort-Object LastWriteTime | Select-Object -last 1 + $msiFile = Get-ChildItem -Path "$ReleaseFolder\*.msi" | Sort-Object LastWriteTime | Select-Object -last 1 if (![string]::IsNullOrEmpty($msiFile)) { + Write-Output "UpdateChannel: $UpdateChannel" + Write-Output "msiFile: $msiFile" $checksum = (Get-FileHash $msiFile -Algorithm SHA512).Hash $file_size = (Get-ChildItem $msiFile).Length $a = Get-Content $websiteJsonReleaseFile | ConvertFrom-Json @@ -71,7 +69,7 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - $GithubTag = "$((Get-Date).ToUniversalTime().ToString("yyyyMMdd"))-$TagName-NB" $html_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/tag/$GithubTag" $browser_download_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/download/$GithubTag/$($msiFile.Name)" - $a.nightlybuild.name = "v$TagName" + $a.nightlybuild.name = "v$TagName-NB" $a.nightlybuild.published_at = $published_at $a.nightlybuild.html_url = $html_url $a.nightlybuild.assets.installer.browser_download_url = $browser_download_url @@ -83,7 +81,7 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - $GithubTag = "$TagName-PB" $html_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/tag/$GithubTag" $browser_download_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/download/$GithubTag/$($msiFile.Name)" - $a.prerelease.name = "v$TagName" + $a.prerelease.name = "v$TagName-PB" $a.prerelease.published_at = $published_at $a.prerelease.html_url = $html_url $a.prerelease.assets.installer.browser_download_url = $browser_download_url @@ -108,8 +106,10 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - # portable - $zipFile = Get-ChildItem -Path "$releaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1 + $zipFile = Get-ChildItem -Path "$ReleaseFolder\*.zip" -Exclude "*-symbols-*.zip" | Sort-Object LastWriteTime | Select-Object -last 1 if (![string]::IsNullOrEmpty($zipFile)) { + Write-Output "UpdateChannel: $UpdateChannel" + Write-Output "zipFile: $zipFile" $checksum = (Get-FileHash $zipFile -Algorithm SHA512).Hash $file_size = (Get-ChildItem $zipFile).Length $a = Get-Content $websiteJsonReleaseFile | ConvertFrom-Json @@ -118,7 +118,7 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - $GithubTag = "$((Get-Date).ToUniversalTime().ToString("yyyyMMdd"))-$TagName-NB" $html_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/tag/$GithubTag" $browser_download_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/download/$GithubTag/$($zipFile.Name)" - $a.nightlybuild.name = "v$TagName" + $a.nightlybuild.name = "v$TagName-NB" $a.nightlybuild.published_at = $published_at $a.nightlybuild.html_url = $html_url $a.nightlybuild.assets.portable.browser_download_url = $browser_download_url @@ -130,7 +130,7 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - $GithubTag = "$TagName-PB" $html_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/tag/$GithubTag" $browser_download_url = "https://github.com/$WebsiteTargetOwner/$MainRepository/releases/download/$GithubTag/$($zipFile.Name)" - $a.prerelease.name = "v$TagName" + $a.prerelease.name = "v$TagName-PB" $a.prerelease.published_at = $published_at $a.prerelease.html_url = $html_url $a.prerelease.assets.portable.browser_download_url = $browser_download_url @@ -153,20 +153,21 @@ if ($UpdateChannel -ne "" -and $buildFolder -ne "" -and $MainRepository -ne "" - } } - $a | ConvertTo-Json -Depth 10 | set-content $websiteJsonReleaseFile + $a | ConvertTo-Json -Depth 10 | Set-Content $websiteJsonReleaseFile # commit releases.json change if ($env:WEBSITE_UPDATE_ENABLED.ToLower() -eq "true") { Write-Output "publish releases.json" - if (Test-Path -Path "$releaseFolder\releases.json") { - $releases_json_string = Get-Content "$releaseFolder\releases.json" | Out-String + if (Test-Path -Path "$ReleaseFolder\releases.json") { + $releases_json_string = Get-Content "$ReleaseFolder\releases.json" | Out-String Set-GitHubContent -OwnerName $WebsiteTargetOwner -RepositoryName $WebsiteTargetRepository -Path _data\releases.json -CommitMessage "Updated for $UpdateChannel $ModifiedTagName" -Content $releases_json_string -BranchName main + Write-Output "publish completed" } } - } else { - write-host "BuildFolder not found" + Write-Output "ReleaseFolder not found" } -Write-Output "End update_and_upload_website_release_json_file.ps1" +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/Tools/validate_microsoft_tool.ps1 b/Tools/validate_microsoft_tool.ps1 index 96329658..f4dde05b 100644 --- a/Tools/validate_microsoft_tool.ps1 +++ b/Tools/validate_microsoft_tool.ps1 @@ -5,7 +5,13 @@ param ( $FullPath ) -$validMSCertThumbprints = @("3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC", "108E2BA23632620C427C570B6D9DB51AC31387FE", "98ED99A67886D020C564923B7DF25E9AC019DF26", "5EAD300DC7E4D637948ECB0ED829A072BD152E17") +$validMSCertThumbprints = @( + "3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC", + "108E2BA23632620C427C570B6D9DB51AC31387FE", + "98ED99A67886D020C564923B7DF25E9AC019DF26", + "5EAD300DC7E4D637948ECB0ED829A072BD152E17", + "97221B97098F37A135DCC212E2B41E452BCE51F2" +) $exeSignature = Get-AuthenticodeSignature -FilePath $FullPath $baseErrorMsg = "Could not validate the certificate of $FullPath. " @@ -14,4 +20,4 @@ if ($exeSignature.Status -ne "Valid") { } elseif ($validMSCertThumbprints -notcontains $exeSignature.SignerCertificate.Thumbprint) { Write-Error -Message ($baseErrorMsg+"The certificate thumbprint ($($exeSignature.SignerCertificate.Thumbprint)) is not trusted.") -ErrorAction Stop -} \ No newline at end of file +} diff --git a/Tools/verify_LargeAddressAware.ps1 b/Tools/verify_LargeAddressAware.ps1 index 0c77bef8..7ab58266 100644 --- a/Tools/verify_LargeAddressAware.ps1 +++ b/Tools/verify_LargeAddressAware.ps1 @@ -10,7 +10,8 @@ param ( $TargetFileName ) -Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) =====" +Write-Output "" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" $path_dumpBin = Join-Path -Path $PSScriptRoot -ChildPath "exes\dumpbin.exe" $path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName @@ -18,7 +19,7 @@ $path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName # Dump exe header $output = & "$path_dumpBin" /NOLOGO /HEADERS "$path_outputExe" | Select-String large -if ($output -eq $null) +if ($null -eq $output) { Write-Warning "Could not validate LargeAddressAware" } @@ -27,4 +28,5 @@ else Write-Output $output.ToString().TrimStart(" ") } -Write-Output "" \ No newline at end of file +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/Tools/verify_binary_signatures.ps1 b/Tools/verify_binary_signatures.ps1 index 2cd64091..5482c11e 100644 --- a/Tools/verify_binary_signatures.ps1 +++ b/Tools/verify_binary_signatures.ps1 @@ -18,13 +18,15 @@ param ( $SolutionDir ) -Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) =====" +Write-Output "" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" +$IsAppVeyor = !([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) # validate release versions and if the certificate value was passed if ($ConfigurationName -match "Release" -And ($CertificatePath)) { - if(-Not ([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) ) { + if($IsAppVeyor) { $CertificatePath = Join-Path -Path $SolutionDir -ChildPath $CertificatePath } @@ -37,9 +39,10 @@ if ($ConfigurationName -match "Release" -And ($CertificatePath)) { Write-Output "Verifying signature of binaries" Write-Output "Getting files from path: $TargetDir" - $signableFiles = Get-ChildItem -Path $TargetDir -Recurse | ?{$_.Extension -match "dll|exe|msi"} + $signableFiles = Get-ChildItem -Path $TargetDir -Recurse | Where-Object {$_.Extension -match "dll|exe|msi"} Write-Output "Signable files count: $($signableFiles.Count)" $badSignatureFound = $false + foreach ($file in $signableFiles) { $signature = Get-AuthenticodeSignature -FilePath $file.FullName if ($signature.Status -ne "Valid") { @@ -47,6 +50,7 @@ if ($ConfigurationName -match "Release" -And ($CertificatePath)) { $badSignatureFound = $true } } + if ($badSignatureFound) { Write-Output "One or more files were improperly signed." } else { @@ -57,4 +61,5 @@ if ($ConfigurationName -match "Release" -And ($CertificatePath)) { Write-Output "Config: $($ConfigurationName)`tCertPath: $($CertificatePath)" } -Write-Output "" \ No newline at end of file +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/Tools/zip_files.ps1 b/Tools/zip_files.ps1 index f5b2fcf3..7e8e3b4a 100644 --- a/Tools/zip_files.ps1 +++ b/Tools/zip_files.ps1 @@ -13,7 +13,9 @@ ) Write-Output "" -Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) =====" +Write-Output "===== Begin $($PSCmdlet.MyInvocation.MyCommand) =====" + +$IsAppVeyor = !([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER)) $ConfigurationName = $ConfigurationName.Trim() Write-Output "Config Name (trimmed): '$($ConfigurationName)'" @@ -21,38 +23,52 @@ $exe = Join-Path -Path $TargetDir -ChildPath $TargetFileName $version = ((Get-Item -Path $exe).VersionInfo | Select-Object -Property ProductVersion)."ProductVersion" Write-Output "Version is $($version)" +# determine update channel +if ($env:APPVEYOR_PROJECT_NAME -match "(Nightly)") { + Write-Output "UpdateChannel = Nightly" + $ModifiedVersion = "$version-NB" +} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Preview)") { + Write-Output "UpdateChannel = Preview" + $ModifiedVersion = "$version-PB" +} elseif ($env:APPVEYOR_PROJECT_NAME -match "(Stable)") { + Write-Output "UpdateChannel = Stable" + $ModifiedVersion = $version +} else { +} + # Fix for AppVeyor -if(!([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER))) { - if(!(test-path "Release")) { +if($IsAppVeyor) { + if(!(Test-Path "Release")) { New-Item -ItemType Directory -Force -Path "Release" | Out-Null } } # Package debug symbols zip file if ($ConfigurationName -match "Release") { + Write-Output "Packaging debug symbols" if ($ConfigurationName -match "Portable") { $zipFilePrefix = "mRemoteNG-Portable-symbols" } else { - $zipFilePrefix = "mRemoteNG-symbols" + $zipFilePrefix = "mRemoteNG-Installer-symbols" } $debugFile = Join-Path -Path $TargetDir -ChildPath "mRemoteNG.pdb" # AppVeyor build - if(!([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER))) { - $outputZipPath = Join-Path -Path $SolutionDir -ChildPath "Release\$zipFilePrefix-$($version).zip" + if ($IsAppVeyor) { + $outputZipPath = Join-Path -Path $SolutionDir -ChildPath "Release\$zipFilePrefix-$($ModifiedVersion).zip" 7z a $outputZipPath $debugFile } # Local build else { if (!(Test-Path -Path $debugFile -PathType Leaf)) { - $outputZipPath = "$($SolutionDir)Release\$zipFilePrefix-$($version).zip" + $outputZipPath = "$($SolutionDir)Release\$zipFilePrefix-$($ModifiedVersion).zip" Compress-Archive $debugFile $outputZipPath -Force } else { - write-host "File do not exist:" $debugFile", nothing to compress" + Write-Output "File do not exist:" $debugFile", nothing to compress" } } @@ -64,20 +80,21 @@ if ($ConfigurationName -eq "Release Portable") { Write-Output "Packaging portable ZIP file" # AppVeyor build - if(!([string]::IsNullOrEmpty($Env:APPVEYOR_BUILD_FOLDER))) { - $outputZipPath = Join-Path -Path $SolutionDir -ChildPath "Release\mRemoteNG-Portable-$($version).zip" + if ($IsAppVeyor) { + $outputZipPath = Join-Path -Path $SolutionDir -ChildPath "Release\mRemoteNG-Portable-$($ModifiedVersion).zip" 7z a -bt -bd -bb1 -mx=9 -tzip -y -r $outputZipPath $TargetDir\* } # Local build else { if ($Source) { - $outputZipPath="$($SolutionDir)\Release\mRemoteNG-Portable-$($version).zip" + $outputZipPath="$($SolutionDir)\Release\mRemoteNG-Portable-$($ModifiedVersion).zip" Compress-Archive $Source $outputZipPath -Force } else { - write-host "File do not exist:" $Source", nothing to compress" + Write-Output "File do not exist:" $Source", nothing to compress" } } } -Write-Output "" \ No newline at end of file +Write-Output "End $($PSCmdlet.MyInvocation.MyCommand)" +Write-Output "" diff --git a/mRemoteNG/mRemoteNG.csproj b/mRemoteNG/mRemoteNG.csproj index 363418fe..93b2569f 100644 --- a/mRemoteNG/mRemoteNG.csproj +++ b/mRemoteNG/mRemoteNG.csproj @@ -480,7 +480,7 @@ - +