forked from axodox/unpaint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_app.ps1
40 lines (34 loc) · 1.74 KB
/
build_app.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
33
34
35
36
37
38
39
40
# Initialize build environment
Write-Host 'Update dependencies...' -ForegroundColor Magenta
.\update_dependencies.ps1
.\Tools\nuget.exe restore .\Unpaint.sln
Write-Host 'Finding Visual Studio...' -ForegroundColor Magenta
$vsPath = .\Tools\vswhere.exe -latest -property installationPath
Write-Host $vsPath
Write-Host 'Importing environment variables...' -ForegroundColor Magenta
cmd.exe /c "call `"$vsPath\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$") {
Set-Content "env:\$($matches[1])" $matches[2]
}
}
# Build projects
Write-Host 'Patching appx manifest...' -ForegroundColor Magenta
$version = if ($null -ne $env:APPVEYOR_BUILD_VERSION) { $env:APPVEYOR_BUILD_VERSION } else { "1.0.0.0" }
[XML]$appManifest = Get-Content "$PSScriptRoot/Unpaint/Package.appxmanifest"
$appManifest.Package.Identity.Version = $version
$appManifest.Save("$PSScriptRoot/Unpaint/Package.appxmanifest")
certutil -importpfx -p $env:UNPAINT_CERT_PW -f -user .\Unpaint\key.pfx NoRoot
$coreCount = (Get-CimInstance -class Win32_ComputerSystem).NumberOfLogicalProcessors
$configurations = "Release"
$platforms = "x64"
foreach ($platform in $platforms) {
foreach ($config in $configurations) {
Write-Host "Building $platform $config..." -ForegroundColor Magenta
MSBuild.exe .\Unpaint.sln -p:Configuration=$config -p:Platform=$platform -m:$coreCount -v:m
}
}
# Pack app
Write-Host 'Creating output directory...' -ForegroundColor Magenta
$packagePath = ".\Unpaint\bin\Release\x64\Unpaint_$($version)_x64.msix"
signtool.exe sign /fd SHA256 /td SHA256 /a /f "./Unpaint/key.pfx" /p $env:UNPAINT_CERT_PW /tr https://timestamp.digicert.com $packagePath