-
Notifications
You must be signed in to change notification settings - Fork 589
/
Generate-VerificationFile.ps1
32 lines (26 loc) · 1.27 KB
/
Generate-VerificationFile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
param(
[Parameter(Mandatory=$true, HelpMessage="Released version of ServiceBusExplorer")]
[string] $Version,
[Parameter(Mandatory=$true, HelpMessage="Path to the ServiceBusExplorer exe")]
[string] $ExePath,
[Parameter(Mandatory=$true, HelpMessage="Location of the VERIFICATION.txt template")]
[string] $TemplateFilePath,
[Parameter(Mandatory=$true, HelpMessage="Location to output the result to")]
[string] $OutputFilePath
)
Write-Output "Creating VERIFICATION.txt based on template '$($TemplateFilePath)' for '$($ExePath)'"
# Get content of template
$rawTemplate = Get-Content $TemplateFilePath | Out-String
Write-Output "VERIFICATION.txt template: $($rawTemplate)"
# Hash ServiceBusExplorer.exe
$hashResult = Get-FileHash $ExePath -Algorithm MD5
Write-Output "Created hash '$($hashResult.Hash)'"
# Update template with checksum
$rawTemplate = $rawTemplate.Replace('%CHECKSUM%', $hashResult.Hash)
Write-Output "Replaced checksum in template with '$($hashResult.Hash)'"
# Updating template with version
$rawTemplate = $rawTemplate.Replace('%VERSION%', $Version)
Write-Output "Replaced version in template with '$($Version)'"
# Store output in VERIFICATION file
New-Item -Path $OutputFilePath -Value $rawTemplate -Force
Write-Host "Wrote results to $($OutputFilePath)"