forked from gpmagvs/VMSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-patch-zip-file.ps1
More file actions
98 lines (83 loc) · 2.58 KB
/
create-patch-zip-file.ps1
File metadata and controls
98 lines (83 loc) · 2.58 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
param (
[string]$outputPath = "C:\GPM Worksapce\AGV_Project\Codes\VMSystem\bin\Release\net8.0\publish",
[string]$includeswwwroot = "false"
)
# 將字串轉成布林
$includeswwwrootBool = $false
if ($includeswwwroot.ToLower() -eq "true") {
$includeswwwrootBool = $true
}
Write-Host "壓縮 wwwroot 目錄 ? :$includeswwwrootBool"
# 確認路徑存在
if (-Not (Test-Path $outputPath)) {
Write-Host "❌ 指定的資料夾不存在:$outputPath"
exit 1
}
# 解析 GPM_VCS.dll 的版本號
$gpmDllPath = Join-Path $outputPath "VMSystem.dll"
$version = "0.0.0.0"
if (Test-Path $gpmDllPath) {
$fileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($gpmDllPath)
$version = $fileVersionInfo.FileVersion
Write-Host "🔍 VMSystem.dll 版本號:$version"
} else {
Write-Host "⚠️ 找不到 VMSystem.dll,無法解析版本號"
$version = "unknown"
}
# 要包含的檔案與資料夾(相對於 outputPath)
$includeItems = @(
"version.json",
"web.config",
"VMSystem.deps.json",
"VMSystem.exe",
"VMSystem.dll",
"VMSystem.pdb",
"VMSystem.xml",
"VMSystem.staticwebassets.endpoints.json",
"AGVSystemCommonNet6.dll",
"AGVSystemCommonNet6.pdb",
"KGSWebAGVSystemAPI.dll",
"KGSWebAGVSystemAPI.pdb",
"RosBridgeClient.dll",
"RosBridgeClient.pdb",
"EquipmentManagment.dll",
"EquipmentManagment.pdb",
"Polly.Core.dll",
"Polly.dll",
"INIFileParser.dll",
"Swashbuckle.AspNetCore.SwaggerUI.dll",
"Swashbuckle.AspNetCore.SwaggerGen.dll",
"Swashbuckle.AspNetCore.Swagger.dll"
)
# 根據參數決定是否加入 wwwroot
if ($includeswwwrootBool) {
$includeItems += "wwwroot"
}
# 濾出存在的項目
$existingItems = @()
foreach ($item in $includeItems) {
$fullPath = Join-Path $outputPath $item
if (Test-Path $fullPath) {
$existingItems += $item
} else {
Write-Host "⚠️ 項目不存在,將略過:$item"
}
}
if ($existingItems.Count -eq 0) {
Write-Host "❌ 沒有任何可壓縮的項目,結束執行。"
exit 1
}
# 建立壓縮檔名與路徑
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
if ($includeswwwrootBool){
$zipFileName = "VMSystem_patch_with_wwwroot_v"+$version+"_$timestamp.zip"
}
else{
$zipFileName = "VMSystem_patch_v"+$version+"_$timestamp.zip"
}
$zipFilePath = Join-Path -Path $outputPath -ChildPath $zipFileName
# 切換目錄後壓縮(保留相對結構)
Push-Location $outputPath
Compress-Archive -Path $existingItems -DestinationPath $zipFilePath
Pop-Location
Write-Host "✅ 壓縮完成:$zipFilePath"