-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildModZip.ps1
More file actions
62 lines (49 loc) · 1.94 KB
/
Copy pathBuildModZip.ps1
File metadata and controls
62 lines (49 loc) · 1.94 KB
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
#!powershell.exe -ExecutionPolicy Bypass -File
param(
[String]$Configuration="Release"
)
. ./BuildInfo.ps1
# 1. Build solution
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$solutionPath = Join-Path $scriptDir "$solutionName.sln"
if (-not (Test-Path $solutionPath)) {
Write-Error "Solution file not found at $solutionPath"
exit 1
}
Write-Output "Building solution $solutionPath in configuration $Configuration..."
$buildOutput = MSBuild.exe $solutionPath /property:Configuration=$Configuration /property:Platform=x64 /t:Rebuild | Tee-Object -FilePath 'build.log'
# 2. Extract version number from build output
$pattern = '\s*Build Version:\s*(?<ver>\d+(\.\d+){3})'
$match = $buildOutput | Select-String -Pattern $pattern -AllMatches
if (-not $match) {
Write-Error "Could not find 'Build Version' in build output."
exit 1
}
$version = $match[0].Matches[0].Groups['ver'].Value
Write-Output "Extracted version: $version"
# 3. Prepare temporary output directory
$outputRoot = Join-Path $scriptDir 'Output'
if (-not (Test-Path $outputRoot)) {
New-Item -ItemType Directory -Path $outputRoot -Force | Out-Null
}
$destRoot = Join-Path $outputRoot "$zipName-$version"
New-Item -ItemType Directory -Path $destRoot -Force | Out-Null
foreach ($item in $allFiles) {
$destDir = Join-Path $destRoot $item[2]
if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir -Force | Out-Null }
}
# 4. Perform copies
foreach ($item in $allFiles) {
$files = $item[0]
$sourceDir = $item[1]
$destDir = Join-Path $destRoot $item[2]
CopyFiles $files $sourceDir $destDir
}
# 5. Zip files
$zipName = "$zipName-$version.7z"
$zipPath = Join-Path $outputRoot $zipName
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
7z a -t7z -mx=9 -ms=on -mmt=on $zipPath (Join-Path $destRoot '*')
Write-Output "Created $zipName"
# 7. Open Output folder in explorer
Start-Process -FilePath "explorer.exe" -ArgumentList $outputRoot