diff --git a/.github/workflows/win-exe.yml b/.github/workflows/win-exe.yml index 62d72215d..4b8f4d2d4 100644 --- a/.github/workflows/win-exe.yml +++ b/.github/workflows/win-exe.yml @@ -59,9 +59,6 @@ jobs: java-dist: 'liberica' java-version: '24.0.1+11' java-package: 'jdk+fx' #This is needed, as liberica contains JFX 24 Jmods for Windows ARM64 - env: - LOOPBACK_ALIAS: 'cryptomator-vault' - WIN_CONSOLE_FLAG: '' steps: - uses: actions/checkout@v4 - name: Setup Java @@ -172,16 +169,6 @@ jobs: - name: Patch Application Directory run: | cp dist/win/contrib/* appdir/Cryptomator - - name: Set LOOPBACK_ALIAS in patchWebDAV.bat - shell: pwsh - run: | - $patchScript = "appdir\Cryptomator\patchWebDAV.bat" - try { - (Get-Content $patchScript ) -replace '::REPLACE ME', "SET LOOPBACK_ALIAS=`"${{ env.LOOPBACK_ALIAS}}`"" | Set-Content $patchScript - } catch { - Write-Host "Failed to set LOOPBACK_ALIAS for patchWebDAV.bat" - exit 1 - } - name: Fix permissions run: | attrib -r appdir/Cryptomator/Cryptomator.exe diff --git a/dist/win/build.ps1 b/dist/win/build.ps1 index 272b6e50b..a5bbfa03f 100644 --- a/dist/win/build.ps1 +++ b/dist/win/build.ps1 @@ -206,14 +206,6 @@ if ($LASTEXITCODE -ne 0) { Copy-Item "contrib\*" -Destination "$AppName" attrib -r "$AppName\$AppName.exe" attrib -r "$AppName\${AppName} (Debug).exe" -# patch batch script to set hostfile -$webDAVPatcher = "$AppName\patchWebDAV.bat" -try { - (Get-Content $webDAVPatcher ) -replace '::REPLACE ME', "SET LOOPBACK_ALIAS=`"$LoopbackAlias`"" | Set-Content $webDAVPatcher -} catch { - Write-Host "Failed to set LOOPBACK_ALIAS for patchWebDAV.bat" - exit 1 -} # create .msi $Env:JP_WIXWIZARD_RESOURCES = "$buildDir\resources" @@ -299,9 +291,9 @@ return 0; # ============================ if ($clean) { Write-Host "Cleaning up previous build artifacts..." - Remove-Item -Path ".\runtime" -Force -Recurse -ErrorAction Ignore - Remove-Item -Path ".\$AppName" -Force -Recurse -ErrorAction Ignore - Remove-Item -Path ".\installer" -Force -Recurse -ErrorAction Ignore + Remove-Item -Path ".\runtime" -Force -Recurse -ErrorAction Ignore -ProgressAction SilentlyContinue + Remove-Item -Path ".\$AppName" -Force -Recurse -ErrorAction Ignore -ProgressAction SilentlyContinue + Remove-Item -Path ".\installer" -Force -Recurse -ErrorAction Ignore -ProgressAction SilentlyContinue } return Main diff --git a/dist/win/contrib/patchUpdateCheck.ps1 b/dist/win/contrib/patchUpdateCheck.ps1 index 3bb3cac15..44001d22b 100644 --- a/dist/win/contrib/patchUpdateCheck.ps1 +++ b/dist/win/contrib/patchUpdateCheck.ps1 @@ -20,30 +20,36 @@ try { Write-Host "Setting cryptomator.disableUpdateCheck to: $shouldDisable" if (-not $shouldDisable) { - Write-Host "Disable-Update-Check property is by default 'false'. Skipping config modification." + Write-Host 'Disable-Update-Check property is by default "false". Skipping config modification.' exit 0 } # Determine the .cfg file path - $cfgFile = Join-Path $($PSScriptRoot) "app\Cryptomator.cfg" + $cfgDir = Join-Path $PSScriptRoot 'app' + $cfgFiles = Get-ChildItem -Path $cfgDir -Filter '*.cfg' -File - if (-not (Test-Path $cfgFile)) { - Write-Error "Configuration file not found at: $cfgFile" + if ($cfgFiles.Count -eq 0) { + Write-Error "No .cfg file found in directory: $cfgDir" exit 1 } - # Read the current configuration - $content = Get-Content $cfgFile -Raw + foreach ($file in $cfgFiles) { + $cfgFile = $file.FullName + Write-Host "Modifying configuration file: $cfgFile" + # Read the current configuration + $content = Get-Content $cfgFile -Raw -ErrorAction Stop - # Add the new option based on the property value - # Use regular expressions substitutions to replace the property - $searchExpression = '(?java-options=-Dcryptomator\.disableUpdateCheck)=false' - $replacementExpression = '${Prefix}=true' - $content = $content -replace $searchExpression,$replacementExpression + # Add the new option based on the property value + # Use regular expressions substitutions to replace the property + $searchExpression = '(?java-options=-Dcryptomator\.disableUpdateCheck)=false' + $replacementExpression = '${Prefix}=true' + $content = $content -replace $searchExpression,$replacementExpression + + # Write the modified content back + Set-Content -Path $cfgFile -Value $content -NoNewline + Write-Host "Successfully updated $cfgFile" + } - # Write the modified content back - Set-Content -Path $cfgFile -Value $content -NoNewline - Write-Host "Successfully updated $cfgFile" exit 0 } catch { diff --git a/dist/win/contrib/patchWebDAV.bat b/dist/win/contrib/patchWebDAV.bat index 735cfb823..3a90d3de3 100644 --- a/dist/win/contrib/patchWebDAV.bat +++ b/dist/win/contrib/patchWebDAV.bat @@ -1,7 +1,18 @@ @echo off -:: Default values for Cryptomator builds -::REPLACE ME +:: Batch wrapper for PowerShell script to adjust Windows network settings for the Cryptomator WebDAVAdapter +:: This is executed as a Custom Action during MSI installation +:: This file must be located in the INSTALLDIR +set "LOOPBACK_ALIAS=%1" + +:: Log for debugging +echo LOOPBACK_ALIAS=%LOOPBACK_ALIAS% + +:: Change to INSTALLDIR cd %~dp0 -powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command .\patchWebDAV.ps1^ - -LoopbackAlias %LOOPBACK_ALIAS% \ No newline at end of file +:: Execute the PowerShell script +powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -File .\patchWebDAV.ps1^ + -LoopbackAlias %LOOPBACK_ALIAS% + +:: Return the exit code from PowerShell +exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/dist/win/resources/main.wxs b/dist/win/resources/main.wxs index f63f7514d..1da7be13a 100644 --- a/dist/win/resources/main.wxs +++ b/dist/win/resources/main.wxs @@ -26,6 +26,7 @@ + @@ -131,7 +132,7 @@ - +