-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.ps1
64 lines (54 loc) · 2.24 KB
/
build.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function Invoke-Environment { # https://github.com/majkinetor/posh/blob/master/MM_Admin/Invoke-Environment.ps1
param (
# Any cmd shell command, normally a configuration batch file.
[Parameter(Mandatory = $true)]
[string] $Command
)
$Command = "`"" + $Command + "`""
cmd /c "$Command >nul 2>&1 && set" | . { process {
if ($_ -match '^([^=]+)=(.*)') {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}}
}
$VisualStudioPath = 'C:\Program Files\Microsoft Visual Studio\2022\Community'
if ($null -eq $Env:VSCMD_VER) {
Invoke-Environment "$VisualStudioPath\VC\Auxiliary\Build\vcvars64.bat"
}
$Platforms = 'Win32', 'x64'
$Configurations = 'Debug', 'Release' # Development Release Trace?
$BasePath = $PSScriptRoot
$RepositoryPath = "$BasePath"
$BuildDirectoryName = 'bin'
$BuildBinary = $true
$BuildSetup = $true
$Release = $true
$Date = Get-Date -Format "yyyyMMdd"
$Zip = "C:\Program Files\7-Zip\7z"
$Type = "Rebuild" # Build, Rebuild
if (!(Test-Path "$RepositoryPath\$BuildDirectoryName")) {
New-Item -Path $RepositoryPath -Name $BuildDirectoryName -ItemType Directory
}
if($BuildBinary) {
$Platforms | ForEach-Object {
$Platform = $_
$Configurations | ForEach-Object {
$Configuration = $_
Write-Host "Configuration $Configuration, Platform $Platform"
$Build = Start-Process "msbuild.exe" -ArgumentList "`"mp4.sln`" /t:$Type /p:Configuration=`"$Configuration`";Platform=`"$Platform`" /nodeReuse:false" -WorkingDirectory $RepositoryPath -PassThru -NoNewWindow -Wait
$ExitCode = $Build.ExitCode
Write-Host "Build ExitCode $ExitCode"
if($ExitCode -ne 0) {
throw "Failed to build Configuration $Configuration, Platform $Platform"
}
}
}
}
if($BuildSetup) {
$Build = Start-Process "C:\Program Files (x86)\NSIS\makensisw.exe" -ArgumentList "`"$RepositoryPath\install\Setup.nsi`"" -WorkingDirectory $RepositoryPath -PassThru -NoNewWindow -Wait
$ExitCode = $Build.ExitCode
Write-Host "Makensisw ExitCode $ExitCode"
if($ExitCode -ne 0) {
throw "Failed to build setup"
}
}