|
48 | 48 | |
49 | 49 | - name: Create installer script |
50 | 50 | run: | |
51 | | - $installerScript = @' |
| 51 | + # Create the installer script by writing it directly to avoid nested here-string issues |
| 52 | + $scriptContent = @" |
52 | 53 | # Woodlanders Launcher - Windows Installer with JRE Auto-Download |
53 | 54 | # Auto-generated installer script |
54 | 55 | |
@@ -171,30 +172,8 @@ jobs: |
171 | 172 | } |
172 | 173 | |
173 | 174 | function Create-LauncherScript { |
174 | | - $launcherScript = @' |
175 | | - @echo off |
176 | | - setlocal |
177 | | - |
178 | | - set "APP_DIR=%~dp0" |
179 | | - set "JAVAFX_CACHE=%USERPROFILE%\.cache\woodlanders-javafx" |
180 | | - |
181 | | - if exist "%APP_DIR%jre\bin\java.exe" ( |
182 | | - set "JAVA_CMD=%APP_DIR%jre\bin\java.exe" |
183 | | - ) else ( |
184 | | - set "JAVA_CMD=java" |
185 | | - ) |
186 | | - |
187 | | - "%JAVA_CMD%" -Djavafx.cachedir="%JAVAFX_CACHE%" -jar "%APP_DIR%woodlanders-launcher.jar" |
188 | | - if %ERRORLEVEL% neq 0 ( |
189 | | - echo. |
190 | | - echo Application failed to start. |
191 | | - pause |
192 | | - ) |
193 | | - |
194 | | - endlocal |
195 | | - '@ |
196 | | - |
197 | | - $launcherScript | Out-File -FilePath "$INSTALL_DIR\launcher.bat" -Encoding ASCII -Force |
| 175 | + `$batContent = "@echo off``r``nsetlocal``r``nset APP_DIR=%~dp0``r``nset JAVAFX_CACHE=%USERPROFILE%\.cache\woodlanders-javafx``r``nif exist %APP_DIR%jre\bin\java.exe (set JAVA_CMD=%APP_DIR%jre\bin\java.exe) else (set JAVA_CMD=java)``r``n%JAVA_CMD% -Djavafx.cachedir=%JAVAFX_CACHE% -jar %APP_DIR%woodlanders-launcher.jar``r``nif %ERRORLEVEL% neq 0 (echo. & echo Application failed to start. & pause)``r``nendlocal" |
| 176 | + `$batContent | Out-File -FilePath "`$INSTALL_DIR\launcher.bat" -Encoding ASCII -Force |
198 | 177 | Write-Success "Launcher script created" |
199 | 178 | } |
200 | 179 | |
@@ -282,9 +261,12 @@ jobs: |
282 | 261 | } |
283 | 262 | exit 1 |
284 | 263 | } |
285 | | - '@ |
| 264 | + "@ |
| 265 | + |
| 266 | + # Fix the scriptDir line for ps2exe compatibility |
| 267 | + $scriptContent = $scriptContent -replace '\`$scriptDir = if \(\`$PSScriptRoot\) \{ \`$PSScriptRoot \} else \{ Split-Path -Parent \`$MyInvocation\.MyCommand\.Path \}', '`$scriptDir = if ($PSScriptRoot) { $PSScriptRoot } elseif ($MyInvocation.MyCommand.Path) { Split-Path -Parent $MyInvocation.MyCommand.Path } else { Get-Location | Select-Object -ExpandProperty Path }' |
286 | 268 | |
287 | | - $installerScript | Out-File -FilePath installer-staging\install.ps1 -Encoding UTF8 |
| 269 | + $scriptContent | Out-File -FilePath installer-staging\install.ps1 -Encoding UTF8 |
288 | 270 | |
289 | 271 | - name: Create README for installer |
290 | 272 | run: | |
|
0 commit comments