Merge pull request #524 from mRemoteNG/improve_build_script_compatibility

Improve compatibility with different build environments
This commit is contained in:
David Sparer
2017-05-02 07:57:02 -06:00
committed by GitHub
5 changed files with 86 additions and 10 deletions

View File

@@ -5,6 +5,10 @@ Features/Enhancements:
Added more logging/notifications options
#429: Added Czech translation
General Changes:
----------------
Improved compatability between environments when building mRemoteNG from source
1.75.7005 (2017-04-XX)

47
Tools/find_vstool.ps1 Normal file
View File

@@ -0,0 +1,47 @@
param (
[string]
# Name of the file to find
$FileName
)
function EditBinCertificateIsValid() {
param (
[string]
$Path
)
# Verify file certificate
$valid_microsoft_cert_thumbprints = @(
"3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC",
"98ED99A67886D020C564923B7DF25E9AC019DF26",
"108E2BA23632620C427C570B6D9DB51AC31387FE"
)
$file_signature = Get-AuthenticodeSignature -FilePath $Path
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"
return $false
} else {
return $true
}
}
$rootSearchPaths = @(
[System.IO.Directory]::EnumerateFileSystemEntries("C:\Program Files", "*Visual Studio*", [System.IO.SearchOption]::TopDirectoryOnly),
[System.IO.Directory]::EnumerateFileSystemEntries("C:\Program Files (x86)", "*Visual Studio*", [System.IO.SearchOption]::TopDirectoryOnly)
)
# Returns the first full path to the $FileName that our search can find
foreach ($searchPath in $rootSearchPaths) {
foreach ($visualStudioFolder in $searchPath) {
$matchingExes = [System.IO.Directory]::EnumerateFileSystemEntries($visualStudioFolder, $FileName, [System.IO.SearchOption]::AllDirectories)
foreach ($matchingExe in $matchingExes) {
if (EditBinCertificateIsValid -Path $matchingExe) {
return $matchingExe
}
}
}
}
Write-Error "Could not find any valid file by the name $FileName." -ErrorAction Stop

View File

@@ -41,6 +41,7 @@ Format-Table -AutoSize -Wrap -InputObject @{
& "$PSScriptRoot\copy_puttyng.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir
& "$PSScriptRoot\move_help_files.ps1" -TargetDir $TargetDir
& "$PSScriptRoot\set_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\tidy_files_for_release.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName
& "$PSScriptRoot\sign_binaries.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword -ConfigurationName $ConfigurationName -Exclude $ExcludeFromSigning
& "$PSScriptRoot\verify_binary_signatures.ps1" -TargetDir $TargetDir -ConfigurationName $ConfigurationName

View File

@@ -11,20 +11,12 @@ param (
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# Find editbin.exe
$path_editBin = @((Resolve-Path -Path "C:\Program Files*\Microsoft Visual Studio*\VC\bin\editbin.exe").Path)[0]
# Verify editbin certificate
$microsoft_cert_thumbprint = "3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC"
$editbin_signature = Get-AuthenticodeSignature -FilePath $path_editBin
if (($editbin_signature.Status -ne "Valid") -or ($editbin_signature.SignerCertificate.Thumbprint -ne $microsoft_cert_thumbprint)) {
Write-Error "Could not validate the signature of editbin.exe - we can not set LargeAddressAware" -ErrorAction Stop
}
$path_editBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "editbin.exe"
$path_outputExe = Join-Path -Path $TargetDir -ChildPath $TargetFileName
# Set LargeAddressAware
Write-Output "Setting LargeAddressAware on binary file `"$path_outputExe`""
Write-Output "Setting LargeAddressAware on binary file:`n`"$path_outputExe`" `nwith:`n`"$path_editBin`""
& $path_editBin "/largeaddressaware" "$path_outputExe"
Write-Output ""

View File

@@ -0,0 +1,32 @@
param (
[string]
[Parameter(Mandatory=$true)]
$TargetDir,
[string]
[Parameter(Mandatory=$true)]
$TargetFileName
)
Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
# Find editbin.exe
$path_dumpBin = & "$PSScriptRoot\find_vstool.ps1" -FileName "dumpbin.exe"
$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)
{
Write-Warning "Could not validate LargeAddressAware"
}
else
{
Write-Output $output.ToString().TrimStart(" ")
}
Write-Output ""