-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ps1
More file actions
109 lines (88 loc) · 4.44 KB
/
package.ps1
File metadata and controls
109 lines (88 loc) · 4.44 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
99
100
101
102
103
104
105
106
107
108
109
# package.ps1
$ErrorActionPreference = "Stop"
$solutionDir = $PSScriptRoot
$appDir = Join-Path $solutionDir "App"
$qtBinDir = "C:\Qt\6.10.1\msvc2022_64\bin" # Adjust if needed
# 1. Clean/Create App Directory
if (Test-Path $appDir) { Remove-Item $appDir -Recurse -Force }
New-Item -ItemType Directory -Path $appDir | Out-Null
Write-Host "Created App directory." -ForegroundColor Cyan
# 2. Check for Release Binaries
# Note: Path still assumes folder structure.
# But binary name is ExplorerSelector.exe
$exePath = Join-Path $solutionDir "x64\Release\ExplorerSelector.exe"
$dllPath = Join-Path $solutionDir "x64\Release\SelectorExplorerPlugin.dll"
if (-not (Test-Path $exePath)) {
Write-Warning "Release build of ExplorerSelector.exe not found. Please build Release configuration first."
Exit
}
if (-not (Test-Path $dllPath)) {
Write-Warning "Release build of SelectorExplorerPlugin.dll not found. Please build Release configuration first."
Exit
}
# 3. Copy Binaries
Copy-Item $exePath $appDir
Copy-Item $dllPath $appDir
Write-Host "Copied Binaries." -ForegroundColor Green
# 4. Run windeployqt
$windeployqt = Join-Path $qtBinDir "windeployqt.exe"
if (Test-Path $windeployqt) {
Write-Host "Running windeployqt..." -ForegroundColor Cyan
$exeInApp = Join-Path $appDir "ExplorerSelector.exe"
# Allow windeployqt to copy standard Qt translations to "translations" folder
Start-Process $windeployqt -ArgumentList "--release --compiler-runtime `"$exeInApp`"" -NoNewWindow -Wait
} else {
Write-Warning "windeployqt.exe not found at $qtBinDir. You may need to copy Qt DLLs manually."
}
# 4.1 Copy Application Translations
# Copy our own translations to the same "translations" folder
$i18nSrc = Join-Path $solutionDir "ExplorerSelector\i18n"
$destTranslationsDir = Join-Path $appDir "translations"
if (Test-Path $i18nSrc) {
# Ensure destination exists (windeployqt usually creates it, but to be safe)
if (-not (Test-Path $destTranslationsDir)) {
New-Item -ItemType Directory -Path $destTranslationsDir -Force | Out-Null
}
# Copy app-specific translations
Copy-Item (Join-Path $i18nSrc "explorerselector_*.qm") $destTranslationsDir
Write-Host "Copied Application Translations to $destTranslationsDir" -ForegroundColor Green
}
# 4.2 Copy Qt Licenses (Best Effort)
$qtRootDir = (Get-Item $qtBinDir).Parent.FullName
$licenseFiles = @("LICENSE.txt", "LICENSE.GPL3-EXCEPT", "LICENSE.LGPLv3", "LICENSE.LGPL3", "LGPL_EXCEPTION.txt")
foreach ($file in $licenseFiles) {
$srcPath = Join-Path $qtRootDir $file
if (Test-Path $srcPath) {
Copy-Item $srcPath $appDir
Write-Host "Copied Qt License: $file" -ForegroundColor Green
}
}
# 5. Copy Assets
Copy-Item (Join-Path $solutionDir "Assets") $appDir -Recurse
Write-Host "Copied Assets." -ForegroundColor Green
# 6. Process AppxManifest.xml
$manifestSrc = Join-Path $solutionDir "AppxManifest.xml"
$manifestDst = Join-Path $appDir "AppxManifest.xml"
$manifestContent = Get-Content $manifestSrc -Raw
# Update paths: Remove "ExplorerSelector\x64\Debug\" prefix (if any)
$manifestContent = $manifestContent -replace 'Executable=".*\\ExplorerSelector.exe"', 'Executable="ExplorerSelector.exe"'
$manifestContent = $manifestContent -replace 'Path=".*\\SelectorExplorerPlugin.dll"', 'Path="SelectorExplorerPlugin.dll"'
Set-Content $manifestDst $manifestContent -Encoding UTF8
Write-Host "Updated AppxManifest.xml." -ForegroundColor Green
# 7. Process Install.bat
$installSrc = Join-Path $solutionDir "Install.bat"
$installDst = Join-Path $appDir "Install.bat"
$installContent = Get-Content $installSrc -Raw
# Update DLL path logic to be relative to script
$installContent = $installContent -replace 'Join-Path \$projectRoot "SelectorExplorerPlugin\\x64\\Debug\\SelectorExplorerPlugin.dll"', 'Join-Path $projectRoot "SelectorExplorerPlugin.dll"'
Set-Content $installDst $installContent
Write-Host "Updated Install.bat." -ForegroundColor Green
# 8. Process UnInstall.bat
$uninstallSrc = Join-Path $solutionDir "UnInstall.bat"
$uninstallDst = Join-Path $appDir "UnInstall.bat"
$uninstallContent = Get-Content $uninstallSrc -Raw
# Update DLL path logic
$uninstallContent = $uninstallContent -replace '"\$PSScriptRoot\\SelectorExplorerPlugin\\x64\\Debug\\SelectorExplorerPlugin.dll"', '"$PSScriptRoot\SelectorExplorerPlugin.dll"'
Set-Content $uninstallDst $uninstallContent
Write-Host "Updated UnInstall.bat." -ForegroundColor Green
Write-Host "Packaging Complete! Content is in $appDir" -ForegroundColor Yellow