Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Build Setup without Inno Setup; docs

KnifeLemonf5850a459c0d
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 03237498..62ef2dfd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -79,8 +79,9 @@ jobs:
- name: Test
run: dotnet test Filee.slnx --no-build -c Release --filter "FullyQualifiedName!~Filee.App.Tests" --logger "trx" --results-directory TestResults
- # Compiles installer/Filee.iss against a stub app without compression: catches script errors in about a minute.
- - name: Check installer script
+ # Builds Setup (src/Filee.Setup) around a stub app and runs it in a sandbox: install, update and uninstall into a
+ # scratch folder with a registry file of its own, without administrator rights.
+ - name: Check the installer
shell: pwsh
run: ./build/build-installer.ps1 -CheckOnly
@@ -97,5 +98,7 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: ui-screenshots
- path: tests/Filee.App.Tests/bin/Release/net10.0/screenshots/
+ path: |
+ tests/Filee.App.Tests/bin/Release/net10.0/screenshots/
+ tests/Filee.Setup.Tests/bin/Release/net10.0/screenshots/
if-no-files-found: ignore
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index bfdd71ed..fe2a145b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,7 +1,7 @@
# Builds the Windows installer and publishes it to GitHub Releases.
# Trigger: push a tag like v1.0.0 (git tag v1.0.0 && git push origin v1.0.0)
#
-# Output (build/build-installer.ps1): Filee-<version>-win-Setup.exe (Inno Setup, installer/Filee.iss),
+# Output (build/build-installer.ps1): Filee-<version>-win-Setup.exe (Filee's own installer, src/Filee.Setup),
# Filee-<version>-win-Portable.zip and Filee-<version>-SHA256SUMS.txt.
# Release notes: the version's section of CHANGELOG.md (what changed, for people using Filee), then the list GitHub
# generates from the pull requests merged since the previous release, grouped by label (.github/release.yml), with
@@ -81,7 +81,8 @@ jobs:
if-no-files-found: ignore
# Publishes the app (Release, self-contained, ReadyToRun) with the Explorer menu extension and the bundled rhwp
- # and 7-Zip, then compiles the installer (portable Inno Setup, pinned and verified) and zips the portable copy.
+ # and 7-Zip and the Microsoft C++ runtime, publishes Setup (one self-contained file), appends the app to it as a
+ # checked payload and zips the portable copy.
- name: Build installer and portable zip
shell: pwsh
run: ./build/build-installer.ps1 -Version ${{ steps.version.outputs.value }} -Portable
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c5e7cebd..2023cdd9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -110,10 +110,14 @@ Read [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) first. In short:
Bump `<Version>` in `Directory.Build.props`, merge, then push a tag `vX.Y.Z`. `.github/workflows/release.yml` runs the
tests and `build/build-installer.ps1 -Portable`: it publishes the app (`-p:FileeRelease=true`, which lets it register
Explorer and startup entries), adds the Explorer menu extension and the bundled rhwp and 7-Zip, compiles
-`installer/Filee.iss` with a pinned, portable Inno Setup, and uploads `Filee-X.Y.Z-win-Setup.exe`, the portable zip and
+`src/Filee.Setup` (Filee's own installer) and appends the app to it, and uploads `Filee-X.Y.Z-win-Setup.exe`, the portable zip and
their SHA-256 sums with release notes generated from the merged pull requests.
-To try the installer locally run `pwsh build/build-installer.ps1` (output in `Releases/`). Setup needs administrator
-rights; `pwsh build/build-installer.ps1 -CheckOnly` only compiles the script. The installer's engine page and some of
-its texts are generated from `EngineDownloads` and the app's translations (`build/tools/make-installer-engines.cs`);
-its own texts are in the `[CustomMessages]` section of `installer/Filee.iss` (English, Korean, Simplified Chinese).
+To try the installer locally run `pwsh build/build-installer.ps1` (output in `Releases/`; it fetches the bundled
+engines, the C++ runtime and the Zig toolchain for the Explorer menu into `build/.cache`; run `build/fetch-fonts.ps1`
+first). `pwsh build/build-installer.ps1 -CheckOnly` builds Setup around a stub app and installs, updates and
+uninstalls it in a sandbox. To run the real Setup without touching your PC, give it a scratch folder:
+`Filee-X.Y.Z-win-Setup.exe /SANDBOX=D:\scratch` (registry, Program Files, Start menu, desktop, PATH and `%APPDATA%`
+all go into that folder; no administrator rights are asked for and Filee is not started). Setup's texts are the
+`installer.*` keys of the app's translation files; its engine page uses the app's engine names. See
+[Architecture](docs/ARCHITECTURE.md#windows-installer).
diff --git a/README.ko.md b/README.ko.md
index 0d7a050d..5bf77fea 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -51,6 +51,7 @@
[릴리스](https://github.com/KnifeLemon/Filee/releases/latest)에서 내려받으세요.
- **Windows 10/11**: `Filee-<version>-win-Setup.exe`를 실행하거나, `win-Portable.zip`을 풀고 `Filee.exe`를 실행해요.
+ 설치 프로그램은 Filee가 직접 만든 것이라 Filee와 같은 언어로 안내하고, PC에 따로 설치할 것이 없어요.
설치할 때 탐색기 메뉴, 로그인 시 자동 실행, `filee` 명령, 추가 엔진을 고를 수 있어요.
- **macOS 14 이상** (미리보기): `osx-arm64` 또는 `osx-x64` 패키지를 풀고 `./install.sh`를 실행해요.
아직 공증 전이라, 처음 실행할 때 시스템 설정 → 개인정보 보호 및 보안 → **그래도 열기**로 허용해 주세요.
diff --git a/README.md b/README.md
index a2d7909c..cf01647a 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,9 @@
Download from [Releases](https://github.com/KnifeLemon/Filee/releases/latest).
- **Windows 10/11**: run `Filee-<version>-win-Setup.exe`, or unzip the `win-Portable.zip` and run `Filee.exe`.
- Setup can add the Explorer menu, start at sign-in, the `filee` command and optional engines.
+ Setup is Filee's own installer, in Filee's languages, and needs nothing else on the PC. It can add the Explorer
+ menu, start at sign-in, the `filee` command and optional engines; silent installs take Inno Setup's switches
+ (`/VERYSILENT /SUPPRESSMSGBOXES`).
- **macOS 14+** (preview): unpack the `osx-arm64` or `osx-x64` package and run `./install.sh`.
The build isn't notarized yet, so allow the first start in System Settings → Privacy & Security → **Open Anyway**.
- **Linux x64/ARM64** (preview, Ubuntu 22.04+): unpack the package and run `./install.sh` (no root, needs Python 3).
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 60d19428..d0e335a3 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -51,6 +51,7 @@
从 [Releases](https://github.com/KnifeLemon/Filee/releases/latest) 下载。
- **Windows 10/11** 运行 `Filee-<version>-win-Setup.exe`,或解压 `win-Portable.zip` 后运行 `Filee.exe`。
+ 安装程序是 Filee 自己的,使用与 Filee 相同的语言,电脑上无需另外安装任何组件。
安装时可以添加资源管理器菜单、登录时启动、`filee` 命令和可选引擎。
- **macOS 14 及以上**(预览)解压 `osx-arm64` 或 `osx-x64` 包并运行 `./install.sh`。
目前尚未公证,首次启动时请在系统设置 → 隐私与安全性中点 **仍要打开**。
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 0f0d4fdc..fa673460 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -93,12 +93,9 @@ Windows headers, without a C runtime. Pieces of these projects that can end up i
## Installer
-`Filee-<version>-win-Setup.exe` is built with Inno Setup (a build tool, not part of the app); the setup and uninstall
-programs inside it are Inno Setup's.
-
-| Component | License | Project |
-|---|---|---|
-| Inno Setup (Copyright (C) 1997-2026 Jordan Russell, portions Copyright (C) 2000-2026 Martijn Laan) | Inno Setup License | https://jrsoftware.org/isinfo.php |
+`Filee-<version>-win-Setup.exe` is Filee's own installer (`src/Filee.Setup`, MIT like the app). It contains the
+.NET runtime, Avalonia, SkiaSharp, HarfBuzzSharp, CommunityToolkit.Mvvm and the Noto fonts listed in this file, and
+the published app as its payload. Filee 1.x's installer was built with Inno Setup, which is no longer used.
## Fonts and icons
diff --git a/build/build-installer.ps1 b/build/build-installer.ps1
index 8d316e15..4441c995 100644
--- a/build/build-installer.ps1
+++ b/build/build-installer.ps1
@@ -1,7 +1,7 @@
<#
.SYNOPSIS
- Builds the Windows installer Filee-<version>-win-Setup.exe (installer/Filee.iss) and, with -Portable, the portable
- zip, into -OutputDir.
+ Builds the Windows installer Filee-<version>-win-Setup.exe (Filee's own, src/Filee.Setup) and, with -Portable, the
+ portable zip, into -OutputDir.
.DESCRIPTION
Without -PublishDir the app is published first (Release, self-contained, -p:FileeRelease=true) into
@@ -9,16 +9,18 @@
small engines rhwp and 7-Zip and the Microsoft C++ runtime DLLs next to rhwp.exe and Filee.exe
(fetch-engines.ps1); the large engines are downloaded by the app (engines.json).
- Inno Setup 7 is downloaded once into build/.cache (pinned, SHA-256 verified) and set up there in its own portable
- mode: nothing is installed or registered on the build machine. The installer's engine page is generated from
- EngineDownloads by build/tools/make-installer-engines.cs.
+ Setup itself (src/Filee.Setup) is published as one self-contained, trimmed program (no .NET needed on the PC);
+ build/tools/make-setup.cs appends the publish folder to it as a Brotli payload with a SHA-256 manifest, and the
+ engines Setup offers from EngineDownloads. The portable zip is the publish folder as it is: without Setup's
+ uninstall.exe next to Filee.exe, Filee knows it is a portable copy.
.PARAMETER CheckOnly
- Compiles the script against a stub app without compression, to check installer/Filee.iss quickly (CI).
+ Builds Setup around a stub app (fast compression) and runs it in a sandbox: install, update and uninstall into a
+ scratch folder with its own registry file, nothing on the PC is touched (CI).
.EXAMPLE
pwsh build/build-installer.ps1
- pwsh build/build-installer.ps1 -Version 1.2.0 -Portable
+ pwsh build/build-installer.ps1 -Version 2.0.0 -Portable
pwsh build/build-installer.ps1 -CheckOnly
#>
[CmdletBinding()]
@@ -36,46 +38,6 @@ $ErrorActionPreference = 'Stop'
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$cache = Join-Path $PSScriptRoot '.cache'
-# Inno Setup 7.1.0, 64-bit edition. Update the version, hash and size together
-# (hashes: https://github.com/jrsoftware/issrc/releases, "Verifying Inno Setup Downloads" on jrsoftware.org).
-$innoVersion = '7.1.0'
-$innoSha256 = '0362A383ED217D4C4239B5933866DD96D3EB2102737DA92F80F6057A4B40DF2F'
-$innoSize = 14304168
-$innoUrl = "https://github.com/jrsoftware/issrc/releases/download/is-$($innoVersion.Replace('.', '_'))/innosetup-$innoVersion-x64.exe"
-
-function Get-Iscc {
- $folder = Join-Path $cache "innosetup-$innoVersion"
- $iscc = Join-Path $folder 'ISCC.exe'
- if (Test-Path $iscc) { return $iscc }
-
- New-Item -ItemType Directory -Force -Path $cache | Out-Null
- $setup = Join-Path $cache "innosetup-$innoVersion-x64.exe"
- if (-not ((Test-Path $setup) -and (Get-FileHash $setup -Algorithm SHA256).Hash -eq $innoSha256)) {
- Write-Host "get $innoUrl"
- & curl.exe --fail --location --silent --show-error --connect-timeout 20 --retry 3 --max-time 300 --output $setup $innoUrl
- if ($LASTEXITCODE -ne 0) { throw "curl exit code $LASTEXITCODE" }
- $hash = (Get-FileHash $setup -Algorithm SHA256).Hash
- if ($hash -ne $innoSha256) {
- Remove-Item $setup
- throw "Inno Setup checksum mismatch (got $hash, size $((Get-Item $setup).Length), expected $innoSize bytes)"
- }
- }
-
- # /PORTABLE=1 is Inno Setup's own portable mode: no uninstaller, no file association, no shortcuts, no registry.
- # /CURRENTUSER keeps it from asking for administrator rights.
- Write-Host "unpack Inno Setup $innoVersion (portable)"
- $partial = "$folder.partial"
- Remove-Item $partial -Recurse -Force -ErrorAction SilentlyContinue
- $process = Start-Process -FilePath $setup -Wait -PassThru -ArgumentList @(
- '/PORTABLE=1', '/CURRENTUSER', '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/SP-', '/NOICONS',
- "/DIR=`"$partial`"", "/LOG=`"$cache\innosetup-$innoVersion.log`"")
- if ($process.ExitCode -ne 0 -or -not (Test-Path (Join-Path $partial 'ISCC.exe'))) {
- throw "Inno Setup setup failed with exit code $($process.ExitCode) (see $cache\innosetup-$innoVersion.log)"
- }
- Move-Item $partial $folder
- return $iscc
-}
-
function Invoke-Checked([string]$what, [scriptblock]$command) {
& $command
if ($LASTEXITCODE -ne 0) { throw "$what failed with exit code $LASTEXITCODE" }
@@ -88,11 +50,15 @@ New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
$OutputDir = (Resolve-Path $OutputDir).Path
if ($CheckOnly) {
- # The script only needs a folder with Filee.exe in it.
- $PublishDir = Join-Path $cache 'installer-check\app'
- New-Item -ItemType Directory -Force -Path $PublishDir | Out-Null
+ # A stand-in app: Setup only needs files, Filee.exe among them.
+ $check = Join-Path $cache 'installer-check'
+ Remove-Item $check -Recurse -Force -ErrorAction SilentlyContinue
+ $PublishDir = Join-Path $check 'app'
+ New-Item -ItemType Directory -Force -Path (Join-Path $PublishDir 'cli'), (Join-Path $PublishDir 'engines\rhwp') | Out-Null
Set-Content (Join-Path $PublishDir 'Filee.exe') 'stub' -NoNewline
- $OutputDir = Join-Path $cache 'installer-check'
+ Set-Content (Join-Path $PublishDir 'cli\filee.cmd') "@`"%~dp0..\filee-cli.exe`" %*" -Encoding ascii
+ Set-Content (Join-Path $PublishDir 'engines\rhwp\rhwp.exe') 'stub' -NoNewline
+ $OutputDir = $check
}
elseif (-not $PublishDir) {
$PublishDir = Join-Path $root 'publish\win-x64'
@@ -102,7 +68,7 @@ elseif (-not $PublishDir) {
"-p:Version=$Version" -p:PublishReadyToRun=true -p:FileeRelease=true -o $PublishDir
}
# The command line, in the same folder so it shares the runtime and the engines (filee-cli.exe). Its name can't
- # be filee.exe next to Filee.exe, so the "filee" command is cli\filee.cmd, which the installer can put on PATH.
+ # be filee.exe next to Filee.exe, so the "filee" command is cli\filee.cmd, which Setup can put on PATH.
Invoke-Checked 'dotnet publish (cli)' {
dotnet publish (Join-Path $root 'src\Filee.Cli\Filee.Cli.csproj') -c Release -r win-x64 --self-contained `
"-p:Version=$Version" -p:PublishReadyToRun=true -p:FileeRelease=true -o $PublishDir
@@ -119,29 +85,61 @@ elseif (-not $PublishDir) {
$PublishDir = (Resolve-Path $PublishDir).Path
if (-not (Test-Path (Join-Path $PublishDir 'Filee.exe'))) { throw "Filee.exe is missing in $PublishDir" }
if (-not $CheckOnly) {
- # Without them rhwp and unhwp fail on PCs without the Visual C++ Redistributable (#248).
+ # Without them rhwp and unhwp fail on PCs without the Visual C++ Redistributable (#248). They go into the payload
+ # and the portable zip; Setup checks again after unpacking (RuntimeCheck) on the user's PC.
foreach ($dll in 'vcruntime140.dll', 'engines\rhwp\msvcp140.dll', 'engines\rhwp\vcruntime140.dll') {
if (-not (Test-Path (Join-Path $PublishDir $dll))) { throw "$dll is missing in $PublishDir (see fetch-engines.ps1 -RuntimeTo)" }
}
+ # A leftover from a run of the old installer or of Setup would make the zip an "installed" copy.
+ foreach ($file in 'uninstall.exe', 'uninstall.json', 'unins000.exe') {
+ if (Test-Path (Join-Path $PublishDir $file)) { throw "$file must not be in $PublishDir" }
+ }
+}
+
+# Setup: one self-contained, trimmed program (src/Filee.Setup).
+$setupProgram = Join-Path $cache 'setup'
+Remove-Item $setupProgram -Recurse -Force -ErrorAction SilentlyContinue
+Invoke-Checked 'dotnet publish (setup)' {
+ dotnet publish (Join-Path $root 'src\Filee.Setup\Filee.Setup.csproj') -c Release -r win-x64 -p:FileeSetupPublish=true `
+ "-p:Version=$Version" -o $setupProgram
}
-$iscc = Get-Iscc
+$setupExe = Join-Path $OutputDir "Filee-$Version-win-Setup.exe"
+Write-Host "pack installer $Version"
+$fast = @(if ($CheckOnly) { '--fast' })
Push-Location $root
try {
- Invoke-Checked 'make-installer-engines' { dotnet run build/tools/make-installer-engines.cs -- installer/obj/engines.iss }
+ $program = Join-Path $setupProgram 'Filee.Setup.exe'
+ Invoke-Checked 'make-setup' { dotnet run build/tools/make-setup.cs -- $program $PublishDir $Version $setupExe @fast }
}
finally {
Pop-Location
}
+if (-not (Test-Path $setupExe)) { throw "make-setup did not write $setupExe" }
-Write-Host "compile installer $Version"
-$options = @('/Q', "/DAppVersion=$Version", "/DPublishDir=$PublishDir", "/O$OutputDir")
-if ($CheckOnly) { $options += '--no-compression' }
-Invoke-Checked 'ISCC' { & $iscc @options (Join-Path $root 'installer\Filee.iss') }
-$setupExe = Join-Path $OutputDir "Filee-$Version-win-Setup.exe"
-if (-not (Test-Path $setupExe)) { throw "ISCC did not write $setupExe" }
if ($CheckOnly) {
- Write-Host "installer/Filee.iss compiles"
+ # Install, update and uninstall in a sandbox: a registry file and folders of its own, no administrator rights.
+ $sandbox = Join-Path $check 'sandbox'
+ function Invoke-Setup([string]$exe, [string[]]$arguments) {
+ $process = Start-Process -FilePath $exe -ArgumentList ($arguments + @('/VERYSILENT', '/SUPPRESSMSGBOXES', "/SANDBOX=`"$sandbox`"")) -Wait -PassThru
+ if ($process.ExitCode -ne 0) {
+ Get-ChildItem (Join-Path $sandbox 'Temp') -Filter '*.log' -ErrorAction SilentlyContinue | ForEach-Object { Get-Content $_.FullName }
+ throw "$(Split-Path $exe -Leaf) $arguments failed with exit code $($process.ExitCode)"
+ }
+ }
+ $installed = Join-Path $sandbox 'Program Files\Filee'
+ Invoke-Setup $setupExe @('/MERGETASKS=desktopicon')
+ foreach ($file in 'Filee.exe', 'cli\filee.cmd', 'engines\rhwp\rhwp.exe', 'uninstall.exe', 'uninstall.json') {
+ if (-not (Test-Path (Join-Path $installed $file))) { throw "Setup did not install $file" }
+ }
+ $registry = Get-Content (Join-Path $sandbox 'registry.json') -Raw
+ if ($registry -notmatch 'C8686E06-8327-40A2-B0F7-3DEDD61D9248\}_is1' -or $registry -notmatch 'uninstall\.exe') { throw 'Setup did not write the uninstall entry' }
+ if (-not (Test-Path (Join-Path $sandbox 'Public\Desktop\Filee.lnk'))) { throw 'Setup did not create the desktop shortcut' }
+ Invoke-Setup $setupExe @()
+ Invoke-Setup (Join-Path $installed 'uninstall.exe') @()
+ if (Test-Path $installed) { throw "The uninstaller left $installed" }
+ if ((Get-Content (Join-Path $sandbox 'registry.json') -Raw) -match '_is1') { throw 'The uninstaller left the uninstall entry' }
+ Write-Host "Setup installs, updates and uninstalls (sandbox: $sandbox)"
return
}
diff --git a/build/tools/make-installer-engines.cs b/build/tools/make-installer-engines.cs
deleted file mode 100644
index 2c1379ce..00000000
--- a/build/tools/make-installer-engines.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-// Writes the engine list of the installer's engine page (installer/Filee.iss includes the result): package ids, their
-// components, sizes and which ones are suggested come from EngineDownloads (engines.json), names and texts from the
-// app's translations. So the installer offers exactly what Settings → Engines offers, in the same words.
-// Run by build/build-installer.ps1: dotnet run build/tools/make-installer-engines.cs -- <output .iss>
-#:project ../../src/Filee.Engines/Filee.Engines.csproj
-#:property PublishAot=false
-
-using System.Globalization;
-using System.Text;
-using System.Text.Json;
-using System.Text.RegularExpressions;
-using Filee.Engines.Infrastructure;
-
-if (args.Length != 1)
-{
- Console.Error.WriteLine("usage: dotnet run build/tools/make-installer-engines.cs -- <output .iss>");
- return 2;
-}
-
-var repo = Environment.CurrentDirectory;
-while (!File.Exists(Path.Combine(repo, "Filee.slnx")))
- repo = Path.GetDirectoryName(repo) ?? throw new InvalidOperationException("Run this from inside the Filee repository.");
-
-// [Languages] names in installer/Filee.iss → the app's translation files.
-(string Inno, string App)[] languages = [("en", "en"), ("ko", "ko"), ("zhcn", "zh-CN")];
-var texts = languages.ToDictionary(l => l.Inno, l => Load(Path.Combine(repo, "src", "Filee.App", "Assets", "i18n", l.App + ".json")));
-
-// The file is included in the middle of [Code], where a ";" line would be Pascal: open a section first.
-var iss = new StringBuilder()
- .AppendLine("[CustomMessages]")
- .AppendLine("; Generated by build/tools/make-installer-engines.cs (build/build-installer.ps1 runs it). Do not edit.");
-
-void Message(string name, string key)
-{
- foreach (var (inno, _) in languages)
- iss.AppendLine($"{inno}.{name}={ToInnoMessage(texts[inno][key])}");
-}
-
-Message("EnginesTitle", "setup.title");
-Message("EnginesDescription", "setup.description");
-Message("EnginesNote", "setup.note");
-Message("EngineSizes", "engines.package.size");
-Message("EngineInstalled", "engines.state.installed");
-Message("TaskStartup", "general.start_with_system");
-Message("TaskContextMenu", "general.context_menu");
-foreach (var package in EngineDownloads.Packages)
- Message("Engine_" + package.Id, $"engines.package.{package.Id}.name");
-
-iss.AppendLine()
- .AppendLine("[Code]")
- .AppendLine("procedure AddEngines;")
- .AppendLine("begin");
-foreach (var package in EngineDownloads.Packages)
-{
- // EngineInstaller marks each component's folder under the engines root; LibreOffice extensions ("oxt") sit
- // inside LibreOffice and come with it, so they are not checked separately.
- var markerFolders = package.Components.Where(c => EngineDownloads.Components[c].Kind != "oxt");
- iss.AppendLine(string.Create(CultureInfo.InvariantCulture,
- $" AddEngine('{package.Id}', '{string.Join(',', markerFolders)}', '{FormatBytes(EngineDownloads.DownloadSize(package))}', " +
- $"'{FormatBytes(package.InstalledSize)}', {(EngineDownloads.IsSuggested(package) ? "True" : "False")});"));
-}
-iss.AppendLine("end;");
-
-var output = Path.GetFullPath(args[0]);
-Directory.CreateDirectory(Path.GetDirectoryName(output)!);
-// Inno Setup reads scripts as UTF-8 only when they start with a BOM.
-File.WriteAllText(output, iss.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
-Console.WriteLine($"{EngineDownloads.Packages.Count} engine packages -> {output}");
-return 0;
-
-static Dictionary<string, string> Load(string path)
-{
- using var json = JsonDocument.Parse(File.ReadAllText(path, Encoding.UTF8));
- return json.RootElement.EnumerateObject().ToDictionary(p => p.Name, p => p.Value.GetString() ?? "");
-}
-
-// One line; the app's {0} placeholders become Inno Setup's %1. A literal % would need %% in formatted messages only,
-// so it is simply not allowed.
-static string ToInnoMessage(string text)
-{
- if (text.Contains('%'))
- throw new InvalidOperationException($"'%' is not supported in installer texts: {text}");
- return Regex.Replace(text, @"\{(\d)\}", m => "%" + (int.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture) + 1))
- .ReplaceLineEndings("%n");
-}
-
-// Same rounding as EnginePackageState.FormatBytes in the app ("422 MB", "1.3 GB").
-static string FormatBytes(long bytes) => bytes >= 1_000_000_000
- ? string.Create(CultureInfo.InvariantCulture, $"{bytes / 1_000_000_000.0:0.0} GB")
- : string.Create(CultureInfo.InvariantCulture, $"{Math.Max(1, bytes / 1_000_000)} MB");
diff --git a/build/tools/make-installer-images.cs b/build/tools/make-installer-images.cs
deleted file mode 100644
index 895073b1..00000000
--- a/build/tools/make-installer-images.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Generates the installer's wizard images from the logo (src/Filee.App/Assets/Icons/filee.svg, see make-icon.cs):
-// installer/wizard-light.png and installer/wizard-dark.png, shown on the left of the first and last wizard page.
-// Run from the repository root: dotnet run build/tools/make-installer-images.cs
-#:package Magick.NET-Q8-AnyCPU
-
-using System.Text;
-using System.Text.RegularExpressions;
-using ImageMagick;
-
-// Aspect ratio 164:314 (Inno Setup's image area), sized for 200 % display scaling so it stays sharp.
-const int Width = 430, Height = 824;
-const int LogoSize = 250;
-
-var logo = File.ReadAllText(Path.Combine("src", "Filee.App", "Assets", "Icons", "filee.svg"));
-var logoSize = double.Parse(Regex.Match(logo, "width='(\\d+)'").Groups[1].Value, System.Globalization.CultureInfo.InvariantCulture);
-var shapes = Regex.Match(logo, "<svg[^>]*>(.*)</svg>", RegexOptions.Singleline).Groups[1].Value;
-
-foreach (var (file, background, text) in new[] { ("wizard-light.png", "#F1F0FD", "#3C3489"), ("wizard-dark.png", "#221E4A", "#E4E2FB") })
-{
- var scale = LogoSize / logoSize;
- var left = (Width - LogoSize) / 2.0;
- var top = Height * 0.38 - LogoSize / 2.0;
- var svg = $"<svg xmlns='http://www.w3.org/2000/svg' width='{Width}' height='{Height}' viewBox='0 0 {Width} {Height}'>" +
- $"<rect width='{Width}' height='{Height}' fill='{background}'/>" +
- $"<g transform='translate({left} {top}) scale({scale.ToString(System.Globalization.CultureInfo.InvariantCulture)})'>{shapes}</g>" +
- $"<text x='{Width / 2}' y='{(int)(top + LogoSize + 86)}' text-anchor='middle' font-family='Segoe UI Semibold, Segoe UI' " +
- $"font-weight='600' font-size='64' fill='{text}'>Filee</text></svg>";
- var settings = new MagickReadSettings { BackgroundColor = MagickColors.Transparent, Format = MagickFormat.Svg };
- using var image = new MagickImage(Encoding.UTF8.GetBytes(svg), settings);
- image.Strip();
- image.Write(Path.Combine("installer", file), MagickFormat.Png);
-}
-Console.WriteLine("Wizard images written to installer/");
diff --git a/build/tools/make-setup.cs b/build/tools/make-setup.cs
new file mode 100644
index 00000000..b83dfe27
--- /dev/null
+++ b/build/tools/make-setup.cs
@@ -0,0 +1,50 @@
+// Makes Filee-<version>-win-Setup.exe: appends the published app (a Brotli payload with a SHA-256 manifest, see
+// src/Filee.Setup/Payload/SetupPayload.cs) to the published Setup program. The engines Setup offers on a fresh install
+// come from EngineDownloads (engines.json), so Setup offers exactly what Settings → Engines offers.
+// Run by build/build-installer.ps1:
+// dotnet run build/tools/make-setup.cs -- <Filee.Setup.exe> <publish folder> <version> <output .exe> [--fast]
+// --fast compresses quickly (Brotli quality 5), for checks.
+#:project ../../src/Filee.Setup/Filee.Setup.csproj
+#:project ../../src/Filee.Engines/Filee.Engines.csproj
+#:property PublishAot=false
+
+using System.Diagnostics;
+using System.Reflection;
+using Filee.Engines.Infrastructure;
+using Filee.Setup.Payload;
+
+var fast = args.Contains("--fast");
+var positional = args.Where(a => a != "--fast").ToArray();
+if (positional.Length != 4)
+{
+ Console.Error.WriteLine("usage: dotnet run build/tools/make-setup.cs -- <Filee.Setup.exe> <publish folder> <version> <output .exe> [--fast]");
+ return 2;
+}
+var (program, app, version, output) = (positional[0], positional[1], positional[2], positional[3]);
+if (!File.Exists(Path.Combine(app, "Filee.exe")))
+{
+ Console.Error.WriteLine($"Filee.exe is missing in {app}");
+ return 1;
+}
+
+// EngineInstaller marks every installed component folder with this file; LibreOffice extensions ("oxt") sit inside
+// LibreOffice and come with it, so they have no folder of their own.
+var marker = (string?)typeof(EngineInstaller).GetField("MarkerName", BindingFlags.NonPublic | BindingFlags.Static)?.GetRawConstantValue()
+ ?? throw new InvalidOperationException("EngineInstaller.MarkerName not found");
+var engines = EngineDownloads.Packages
+ .Where(EngineDownloads.CanDownload)
+ .Select(p => new EngineOffer(
+ p.Id,
+ p.Components.Where(c => EngineDownloads.Components[c].Kind != "oxt").ToList(),
+ EngineDownloads.DownloadSize(p),
+ p.InstalledSize,
+ EngineDownloads.IsSuggested(p)))
+ .ToList();
+
+var watch = Stopwatch.StartNew();
+var manifest = SetupPayload.Write(program, app, Path.GetFullPath(output), version, engines, marker,
+ quality: fast ? 5 : 11, window: 24);
+var size = new FileInfo(output).Length;
+Console.WriteLine($"{manifest.Files.Count} files, {manifest.TotalSize / 1_000_000} MB -> {output} ({size / 1_000_000} MB) in {watch.Elapsed.TotalSeconds:0} s; " +
+ $"engines offered: {string.Join(", ", engines.Select(e => e.Suggested ? e.Id + "*" : e.Id))}");
+return 0;
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 69aee0c4..087608b1 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -112,7 +112,7 @@ applied by `WindowsPlatformServices.SetContextMenu` at start-up and whenever set
- The package is **unsigned** (publisher contains `OID.2.25.311729368913984317654407730594956997722=1`; Filee has no
code-signing certificate). Windows only registers an unsigned package with executable content **with
administrator rights** (it installs it for all users); a per-user attempt fails with 0x80073D2B "an unsigned
- package cannot include Executable activations". Setup (`installer/Filee.iss`) has those rights anyway and
+ package cannot include Executable activations". Setup (`src/Filee.Setup`) has those rights anyway and
registers it on Windows 11 x64 while its option is ticked. Later the General page offers "Add to the main menu",
which runs `Add-AppxPackage -Path … -ExternalLocation … -AllowUnsigned` in Windows PowerShell through one UAC
prompt (`ExplorerMenuRegistration`). A signed package would register per user without a prompt.
@@ -126,10 +126,11 @@ applied by `WindowsPlatformServices.SetContextMenu` at start-up and whenever set
- Invoke starts `Filee.exe --convert "<path>"…` next to the DLL and returns at once. Selections longer than a
command line go through `%TEMP%\Filee-convert-*.txt` (`--convert-list`, one path per line), which the app deletes.
- Updates: Setup asks the running Filee to exit (`Filee.exe --quit`), then renames a `FileeExplorerMenu.dll` that
- Explorer still has loaded (Windows allows renaming a loaded DLL, not replacing or deleting it) and has Windows
- delete the old copy at the next restart, so updating needs no restart. An update keeps the registration as it
- was and refreshes it. Uninstall runs `Filee.exe --uninstall-cleanup` (`UninstallCleanup`): it removes the package,
- the title file, the classic verb, the startup entry and downloaded engines; settings stay.
+ Explorer still has loaded into its backup folder (Windows allows renaming a loaded DLL, not replacing or deleting
+ it) and has Windows delete the old copy at the next restart, so updating needs no restart. An update keeps the
+ registration as it was and refreshes it. Uninstall runs `Filee.exe --uninstall-cleanup` (`UninstallCleanup`): it
+ removes the package, the title file, the classic verb, the startup entry and downloaded engines; the uninstaller
+ then asks whether to delete the settings too (they stay by default).
- Build: `pwsh build/build-explorer-menu.ps1` downloads a pinned Zig (SHA-256 checked) into `build/.cache`, compiles
the DLL and packs the MSIX with `build/tools/make-explorer-package.cs` (Windows' own packaging API, no SDK).
Output: `build/.cache/explorer-menu`; CI builds it for the tests, `build/build-installer.ps1` builds it into the
@@ -141,3 +142,44 @@ Debugging: `Get-AppxPackage Filee.ExplorerMenu` shows the registration (`Install
`Add-AppxPackage -Path FileeExplorerMenu.msix -ExternalLocation <folder with Filee.exe> -AllowUnsigned`. Explorer picks
the entry up for new menus; if not, restart Explorer. To remove it by hand:
`Get-AppxPackage Filee.ExplorerMenu | Remove-AppxPackage`.
+
+## Windows installer
+
+`Filee-<version>-win-Setup.exe` is Filee's own installer, `src/Filee.Setup` (it replaced the Inno Setup script of
+1.x). It is an Avalonia program with the app's look and translations: it links `Styles/Soft.axaml` (which therefore
+styles only Avalonia's own controls; Filee's controls are in `Controls.axaml`), `SoftPalette` (accent, radii, font
+order), the Noto fonts and `Assets/i18n/*.json` (Setup's texts are the `installer.*` keys).
+
+- **Build** (`build/build-installer.ps1`): Setup is published as one self-contained, trimmed file
+ (`-p:FileeSetupPublish=true`), so it runs on Windows 10 1809+ x64 without .NET. `build/tools/make-setup.cs` appends
+ the app's publish folder as the payload: `[program][Brotli stream of every file][manifest JSON][72-byte trailer]`
+ (`SetupPayload`). The manifest lists every file with its size and SHA-256, the SHA-256 of the compressed stream, the
+ version and the engines to offer (from `EngineDownloads`). A future signature goes after the trailer (Setup looks
+ for the trailer in front of the certificate table), so sign after packing. The code is trim- and AOT-safe
+ (compiled bindings, source-generated P/Invoke and COM); Native AOT would need the MSVC linker on the build machine
+ and still couldn't link SkiaSharp's native libraries in.
+- **Rights**: Setup starts unelevated (asInvoker) and, for an install for all users, starts itself again with
+ administrator rights (one UAC prompt) and waits. The elevated copy writes what to start at the end into a file
+ (`/LAUNCHFILE`), and the unelevated one starts Filee from it as the signed-in user. Elevated without such a parent
+ (run as administrator, a package manager), it starts Filee with Explorer's token.
+- **Install** (`Installer`): checks the free space and the payload's hash first, closes Filee (`--quit`, then ends
+ what still runs from the folder), unpacks into `<folder>\~setup-*\new` checking every file, checks that every
+ program finds the Microsoft C++ runtime it imports (next to it or in System32; `RuntimeCheck`), then swaps the files
+ in (`FileSwap`: replaced and obsolete files are renamed into a backup, which works for files in use) and writes the
+ uninstall entry, the shortcuts and PATH. Any failure until then puts everything back. Filee's own settings (Explorer
+ menu, start at sign-in, engines, a picked language) are handed to Filee on its command line, as before.
+- **Updates from 1.x**: the uninstall key stays `{C8686E06-8327-40A2-B0F7-3DEDD61D9248}_is1` (Inno Setup's AppId), so
+ Apps & Features keeps one Filee. `PreviousInstall` reads the folder and choices of an Inno Setup installation; an
+ update keeps the folder and what is registered now (desktop shortcut, PATH, the top-level menu package), removes
+ `unins000.*` and every file 2.0 doesn't have, and rewrites the key without the `Inno Setup: …` values. The app
+ counts as installed when `uninstall.exe` (or 1.x's `unins000.exe`) is next to it (`UpdateService.IsInstalled`).
+- **Uninstall**: `uninstall.exe` is Setup without its payload. Run from the install folder it copies itself to
+ `%TEMP%` and waits for the copy, which removes what `uninstall.json` lists (other files in the folder stay), the
+ shortcuts, the PATH entry and the key. Files in use are moved out and deleted at the next restart.
+- **Command line**: Inno Setup's switches (`SetupOptions`, documented at the top of the file), because Filee 1.x
+ updates itself with `/SILENT /NORESTART` and winget passes `/VERYSILENT /SUPPRESSMSGBOXES /NORESTART`. Exit codes as
+ Inno Setup's: 0 done, 1 could not start, 2 cancelled before installing (also a declined UAC prompt), 4 failed.
+- **Testing**: `Filee.Setup.Tests` runs installs, updates (also over a simulated 1.x installation) and uninstalls
+ against `MemoryRegistry`, a fake `ISetupSystem` and scratch folders, and renders every page. `/SANDBOX=<folder>`
+ runs the real Setup with a registry file and all folders inside `<folder>`; `build-installer.ps1 -CheckOnly` (CI)
+ installs, updates and uninstalls that way.
diff --git a/installer/Filee.iss b/installer/Filee.iss
deleted file mode 100644
index 45426a0f..00000000
--- a/installer/Filee.iss
+++ /dev/null
@@ -1,586 +0,0 @@
-; Filee installer (Inno Setup 7). Build it with build/build-installer.ps1, which publishes the app, generates
-; obj\engines.iss (build/tools/make-installer-engines.cs) and runs
-; ISCC.exe /DAppVersion=1.2.0 /DPublishDir=<published app> /O<output folder> installer\Filee.iss
-;
-; Besides copying files it
-; - installs for all users into Program Files (administrator rights, one UAC prompt). Filee itself keeps running as
-; the signed-in user without elevation: Windows blocks drag and drop from Explorer into elevated windows;
-; - closes a running Filee first ("Filee.exe --quit") and moves FileeExplorerMenu.dll aside when Explorer has it
-; loaded, so updates need no restart;
-; - takes over an installation of Filee 1.1 or earlier (Velopack, per user in %LocalAppData%\Filee): removes it but
-; keeps the settings (%APPDATA%\Filee) and downloaded engines (%LocalAppData%\Filee\engines);
-; - on Windows 11 registers the top-level File Explorer menu entry (an unsigned sparse package, which needs the
-; administrator rights Setup already has);
-; - offers the optional conversion engines; Filee downloads the chosen ones (verified) when Setup starts it;
-; - can put the "filee" command line on PATH ({app}\cli\filee.cmd runs filee-cli.exe).
-; The uninstaller runs "Filee.exe --uninstall-cleanup" for the per-user parts (UninstallCleanup.cs).
-
-#ifndef AppVersion
- #error AppVersion is not defined: build with build/build-installer.ps1
-#endif
-#ifndef PublishDir
- #error PublishDir is not defined: build with build/build-installer.ps1
-#endif
-
-#define AppName "Filee"
-#define AppExe "Filee.exe"
-#define RepositoryUrl "https://github.com/KnifeLemon/Filee"
-; Never change: Windows finds the installed Filee by this id (uninstall key "{<id>}_is1").
-#define AppGuid "C8686E06-8327-40A2-B0F7-3DEDD61D9248"
-
-[Setup]
-AppId={{{#AppGuid}}
-AppName={#AppName}
-AppVersion={#AppVersion}
-AppVerName={#AppName} {#AppVersion}
-AppPublisher=Filee contributors
-AppPublisherURL={#RepositoryUrl}
-AppSupportURL={#RepositoryUrl}/issues
-AppUpdatesURL={#RepositoryUrl}/releases
-AppCopyright=Copyright (c) Filee contributors
-VersionInfoVersion={#AppVersion}
-VersionInfoProductName={#AppName}
-SetupArchitecture=x64
-ArchitecturesAllowed=x64compatible
-ArchitecturesInstallIn64BitMode=x64compatible
-MinVersion=10.0.17763
-PrivilegesRequired=admin
-DefaultDirName={autopf}\{#AppName}
-DisableWelcomePage=no
-DisableProgramGroupPage=yes
-UninstallDisplayName={#AppName}
-UninstallDisplayIcon={app}\{#AppExe}
-SetupIconFile=..\src\Filee.App\Assets\Icons\filee.ico
-WizardStyle=modern dynamic
-WizardImageFile=wizard-light.png
-WizardImageFileDynamicDark=wizard-dark.png
-WizardSmallImageFile=..\src\Filee.App\Assets\Icons\filee.png
-OutputBaseFilename=Filee-{#AppVersion}-win-Setup
-Compression=lzma2/ultra64
-SolidCompression=yes
-; Filee is closed by PrepareToInstall; Restart Manager is only the fallback, and only for Filee.exe: with DLLs in the
-; filter it would offer to close Explorer, which loads FileeExplorerMenu.dll.
-CloseApplications=yes
-CloseApplicationsFilter=*.exe
-RestartApplications=no
-; Per-user parts (the old Velopack copy, Start menu shortcuts) belong to the account that runs Setup.
-UsedUserAreasWarning=no
-; The "filee" command folder is added to PATH: tell running programs (new terminals) about it.
-ChangesEnvironment=yes
-SetupLogging=yes
-
-[Languages]
-Name: "en"; MessagesFile: "compiler:Default.isl"
-Name: "ko"; MessagesFile: "compiler:Languages\Korean.isl"
-Name: "zhcn"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
-
-; Texts shared with the app (engine names, the two options of the General page) are generated into obj\engines.iss.
-[CustomMessages]
-en.GroupOptions=Options:
-ko.GroupOptions=옵션:
-zhcn.GroupOptions=选项:
-en.TaskModernMenu=Also show it at the top of the Windows 11 menu, not only under “Show more options”
-ko.TaskModernMenu=Windows 11 기본 메뉴에도 표시 (“추가 옵션 표시”를 누르지 않아도 보여요)
-zhcn.TaskModernMenu=也显示在 Windows 11 主菜单中,而不仅是“显示更多选项”里
-en.StatusRemovingOld=Removing the previous version (settings and engines are kept)...
-ko.StatusRemovingOld=이전 버전을 정리하는 중 (설정과 엔진은 그대로 둬요)...
-zhcn.StatusRemovingOld=正在移除旧版本(保留设置和引擎)...
-en.StatusExplorerMenu=Adding Filee to the File Explorer menu...
-ko.StatusExplorerMenu=탐색기 메뉴에 Filee를 추가하는 중...
-zhcn.StatusExplorerMenu=正在将 Filee 添加到资源管理器菜单...
-en.ExplorerMenuFailed=Windows did not add Filee to the top of the File Explorer menu:%n%n%1%n%nFilee still appears under “Show more options”. You can try again in Filee under Settings → General.
-ko.ExplorerMenuFailed=Windows가 탐색기 기본 메뉴에 Filee를 추가하지 못했어요:%n%n%1%n%nFilee는 “추가 옵션 표시” 안에는 계속 나타나요. Filee의 설정 → 일반에서 다시 시도할 수 있어요.
-zhcn.ExplorerMenuFailed=Windows 未能将 Filee 添加到资源管理器主菜单:%n%n%1%n%nFilee 仍会出现在“显示更多选项”中。你可以在 Filee 的 设置 → 常规 中重试。
-en.ReadyEngines=Conversion engines (Filee downloads them when it starts):
-ko.ReadyEngines=변환 엔진 (Filee가 시작하면서 내려받아요):
-zhcn.ReadyEngines=转换引擎(Filee 启动后下载):
-en.FinishedRunning=Filee is installed and running in the notification area of the taskbar.%n%nTo convert files, drag them while holding the trigger key, or right-click them in File Explorer.
-ko.FinishedRunning=Filee가 설치되어 작업 표시줄 알림 영역에서 실행 중이에요.%n%n파일을 변환하려면 지정한 키를 누른 채 파일을 끌거나, 탐색기에서 파일을 우클릭하세요.
-zhcn.FinishedRunning=Filee 已安装,正在任务栏通知区域运行。%n%n要转换文件,请按住触发键拖动文件,或在资源管理器中右键单击文件。
-en.TaskCli=Add the "filee" command to PATH (convert from the command line)
-ko.TaskCli="filee" 명령어를 PATH에 추가 (명령줄에서 변환)
-zhcn.TaskCli=将 "filee" 命令添加到 PATH(在命令行中转换)
-en.FinishedEngines=The conversion engines you picked are downloading in the Filee window.
-ko.FinishedEngines=선택한 변환 엔진은 Filee 창에서 내려받고 있어요.
-zhcn.FinishedEngines=你选择的转换引擎正在 Filee 窗口中下载。
-
-[Tasks]
-Name: "contextmenu"; Description: "{cm:TaskContextMenu}"; GroupDescription: "{cm:GroupOptions}"; Check: IsFreshInstall
-Name: "contextmenu\top"; Description: "{cm:TaskModernMenu}"; GroupDescription: "{cm:GroupOptions}"; Check: IsFreshInstall and IsExplorerMenuSupported
-Name: "startup"; Description: "{cm:TaskStartup}"; GroupDescription: "{cm:GroupOptions}"; Check: IsFreshInstall
-Name: "cli"; Description: "{cm:TaskCli}"; GroupDescription: "{cm:GroupOptions}"; Check: not IsCliOnPath
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
-
-[Files]
-Source: "{#PublishDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
-
-[Icons]
-Name: "{autoprograms}\{#AppName}"; Filename: "{app}\{#AppExe}"
-Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExe}"; Tasks: desktopicon
-
-[UninstallRun]
-; Quits Filee, then removes the Explorer menu entries, the startup entry and downloaded engines. Settings stay.
-Filename: "{app}\{#AppExe}"; Parameters: "--uninstall-cleanup"; Flags: runhidden waituntilterminated; RunOnceId: "FileeCleanup"
-
-[Code]
-const
- // ExplorerMenuPackage in src/Filee.Platform.Windows (InstallerScriptTests keeps these in sync).
- ExplorerMenuName = 'Filee.ExplorerMenu';
- ExplorerMenuFamily = 'Filee.ExplorerMenu_c73vxh346rtay';
- ExplorerMenuDll = 'FileeExplorerMenu.dll';
- ExplorerMenuPackageFile = 'FileeExplorerMenu.msix';
- ExplorerMenuMinimumBuild = 22000;
- // EngineInstaller marks every installed engine folder with this file.
- EngineMarker = '.filee-component';
- // Filee 1.1 and earlier: Velopack installed it per user and registered it here.
- VelopackUninstallKey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall\Filee';
- ERROR_INSUFFICIENT_BUFFER = 122;
-
-var
- // Filee 1.2 or later is installed already: this run is an update, which keeps the user's choices.
- WasInstalled: Boolean;
- HadVelopackInstall: Boolean;
- ExplorerMenuWasRegistered: Boolean;
- EnginePage: TInputOptionWizardPage;
- // Package id per entry of EnginePage; empty for packages that are installed already.
- EngineIds: TArrayOfString;
-
-function GetPackagesByPackageFamily(PackageFamilyName: String; var Count: Cardinal; PackageFullNames: NativeInt;
- var BufferLength: Cardinal; Buffer: NativeInt): Integer;
- external '[email protected] stdcall delayload';
-
-function IsFreshInstall: Boolean;
-begin
- Result := not WasInstalled;
-end;
-
-function IsExplorerMenuSupported: Boolean;
-var
- Version: TWindowsVersion;
-begin
- // Windows 11 has the new menu; Explorer must be x64 to load the DLL.
- GetWindowsVersionEx(Version);
- Result := (Version.Build >= ExplorerMenuMinimumBuild) and (ProcessorArchitecture = paX64);
-end;
-
-function IsExplorerMenuRegistered: Boolean;
-var
- Count, Length: Cardinal;
-begin
- Count := 0;
- Length := 0;
- try
- Result := (GetPackagesByPackageFamily(ExplorerMenuFamily, Count, 0, Length, 0) = ERROR_INSUFFICIENT_BUFFER) and (Count > 0);
- except
- Result := False;
- end;
-end;
-
-// A PowerShell single-quoted string. PowerShell also takes the typographic quotes as single quotes.
-function PsQuote(const Value: String): String;
-begin
- Result := Value;
- StringChangeEx(Result, '''', '''''', True);
- StringChangeEx(Result, #$2018, #$2018#$2018, True);
- StringChangeEx(Result, #$2019, #$2019#$2019, True);
- StringChangeEx(Result, #$201A, #$201A#$201A, True);
- StringChangeEx(Result, #$201B, #$201B#$201B, True);
- Result := '''' + Result + '''';
-end;
-
-// Runs Windows PowerShell (the Appx cmdlets live there) with the rights of Setup. The command must not contain
-// double quotes; on failure Error gets the exception message without the "NOTE: For additional information" tail.
-function RunPowerShell(const Command: String; var Error: String): Boolean;
-var
- ErrorFile: String;
- Lines: TArrayOfString;
- I, ResultCode, Note: Integer;
-begin
- ErrorFile := ExpandConstant('{tmp}\powershell-error.txt');
- DeleteFile(ErrorFile);
- Result := Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
- '-NoLogo -NoProfile -NonInteractive -Command "$ErrorActionPreference = ''Stop''; try { ' + Command + '; exit 0 } ' +
- 'catch { [IO.File]::WriteAllText(' + PsQuote(ErrorFile) + ', $_.Exception.Message, [Text.Encoding]::UTF8); exit 1 }"',
- '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
- Error := '';
- if Result then
- Exit;
- if LoadStringsFromFile(ErrorFile, Lines) then
- for I := 0 to GetArrayLength(Lines) - 1 do
- if Trim(Lines[I]) <> '' then
- Error := Error + Trim(Lines[I]) + ' ';
- Note := Pos('NOTE: For additional information', Error);
- if Note > 0 then
- Error := Copy(Error, 1, Note - 1);
- Error := Trim(Error);
- if Error = '' then
- Error := Format('PowerShell exit code %d', [ResultCode]);
- Log('PowerShell failed: ' + Error);
-end;
-
-procedure UnregisterExplorerMenu;
-var
- Error: String;
-begin
- RunPowerShell('Get-AppxPackage -Name ' + PsQuote(ExplorerMenuName) + ' | Remove-AppxPackage', Error);
-end;
-
-// Registers the package next to Filee.exe with the install folder as its external location. A fresh install first
-// removes any older registration, which may point to another folder.
-procedure RegisterExplorerMenu(RemoveFirst: Boolean);
-var
- Command, Error: String;
-begin
- WizardForm.StatusLabel.Caption := CustomMessage('StatusExplorerMenu');
- Command := 'Add-AppxPackage -Path ' + PsQuote(ExpandConstant('{app}\') + ExplorerMenuPackageFile) +
- ' -ExternalLocation ' + PsQuote(ExpandConstant('{app}')) + ' -AllowUnsigned -ForceUpdateFromAnyVersion';
- if RemoveFirst then
- Command := 'Get-AppxPackage -Name ' + PsQuote(ExplorerMenuName) + ' | Remove-AppxPackage; ' + Command;
- if not RunPowerShell(Command, Error) and not WizardSilent then
- MsgBox(FmtMessage(CustomMessage('ExplorerMenuFailed'), [Error]), mbError, MB_OK);
-end;
-
-procedure UpdateExplorerMenu;
-begin
- if not IsExplorerMenuSupported then
- Exit;
- if WasInstalled then
- begin
- // An update keeps what was chosen in Filee (Settings > General) and refreshes the registration.
- if ExplorerMenuWasRegistered then
- RegisterExplorerMenu(False);
- end
- else if WizardIsTaskSelected('contextmenu\top') then
- RegisterExplorerMenu(True)
- else if IsExplorerMenuRegistered then
- UnregisterExplorerMenu;
-end;
-
-// Explorer keeps FileeExplorerMenu.dll loaded after showing the menu. A loaded DLL cannot be replaced or deleted, but
-// it can be renamed: move it into Folder (same drive) and let Windows delete it at the next restart.
-procedure MoveLoadedDllAside(const Folder: String);
-var
- Dll, Aside: String;
-begin
- Dll := ExpandConstant('{app}\') + ExplorerMenuDll;
- if not FileExists(Dll) or DeleteFile(Dll) then
- Exit;
- Aside := AddBackslash(Folder) + ExplorerMenuDll + '.' + GetDateTimeString('yyyymmddhhnnss', #0, #0) + '.old';
- if RenameFile(Dll, Aside) then
- RestartReplace(Aside, '')
- else
- Log('Could not move the loaded ' + Dll + ' aside');
-end;
-
-procedure DeleteFileOrSchedule(const Path: String);
-begin
- if FileExists(Path) and not DeleteFile(Path) then
- RestartReplace(Path, '');
-end;
-
-// Deletes a folder tree; what Windows keeps open (a DLL loaded by Explorer) goes at the next restart.
-procedure DeleteTreeOrSchedule(const Dir: String);
-var
- Find: TFindRec;
- Path: String;
-begin
- if not DirExists(Dir) then
- Exit;
- if FindFirst(AddBackslash(Dir) + '*', Find) then
- try
- repeat
- if (Find.Name <> '.') and (Find.Name <> '..') then
- begin
- Path := AddBackslash(Dir) + Find.Name;
- // Never follow junctions or symbolic links out of the folder.
- if (Find.Attributes and FILE_ATTRIBUTE_REPARSE_POINT) <> 0 then
- RemoveDir(Path)
- else if (Find.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then
- DeleteTreeOrSchedule(Path)
- else
- DeleteFileOrSchedule(Path);
- end;
- until not FindNext(Find);
- finally
- FindClose(Find);
- end;
- if not RemoveDir(Dir) then
- RestartReplace(Dir, '');
-end;
-
-// Removes the Velopack installation of Filee 1.1 and earlier without running its uninstaller, which would also
-// delete the downloaded engines. Its registry entries (context menu, startup) are rewritten by the new Filee.
-procedure RemoveVelopackInstall;
-var
- Root: String;
-begin
- WizardForm.StatusLabel.Caption := CustomMessage('StatusRemovingOld');
- // Its Explorer menu entry points into the folder that is deleted next.
- if ExplorerMenuWasRegistered then
- UnregisterExplorerMenu;
- Root := ExpandConstant('{localappdata}\Filee');
- DeleteFileOrSchedule(Root + '\Update.exe');
- DeleteFileOrSchedule(Root + '\Filee.exe');
- DeleteTreeOrSchedule(Root + '\current');
- DeleteTreeOrSchedule(Root + '\packages');
- DeleteFile(ExpandConstant('{userprograms}\Filee.lnk'));
- DeleteFile(ExpandConstant('{userdesktop}\Filee.lnk'));
- RegDeleteKeyIncludingSubkeys(HKCU, VelopackUninstallKey);
-end;
-
-const
- EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
-
-// The folder with filee.cmd (the command line), which goes on the system PATH.
-function CliFolder: String;
-begin
- Result := ExpandConstant('{app}\cli');
-end;
-
-function PathHas(const Paths, Folder: String): Boolean;
-begin
- Result := Pos(';' + Uppercase(RemoveBackslashUnlessRoot(Folder)) + ';', ';' + Uppercase(Paths) + ';') > 0;
-end;
-
-function IsCliOnPath: Boolean;
-var
- Paths: String;
-begin
- Result := RegQueryStringValue(HKLM, EnvironmentKey, 'Path', Paths) and PathHas(Paths, CliFolder);
-end;
-
-procedure AddCliToPath;
-var
- Paths: String;
-begin
- if not RegQueryStringValue(HKLM, EnvironmentKey, 'Path', Paths) or PathHas(Paths, CliFolder) then
- Exit;
- if (Paths <> '') and (Copy(Paths, Length(Paths), 1) <> ';') then
- Paths := Paths + ';';
- // REG_EXPAND_SZ like Windows' own value, so %SystemRoot% entries keep working.
- RegWriteExpandStringValue(HKLM, EnvironmentKey, 'Path', Paths + CliFolder);
-end;
-
-procedure RemoveCliFromPath;
-var
- Paths, Folder: String;
- At: Integer;
-begin
- if not RegQueryStringValue(HKLM, EnvironmentKey, 'Path', Paths) then
- Exit;
- Folder := ';' + Uppercase(CliFolder) + ';';
- Paths := ';' + Paths + ';';
- At := Pos(Folder, Uppercase(Paths));
- if At = 0 then
- Exit;
- Delete(Paths, At, Length(Folder) - 1);
- RegWriteExpandStringValue(HKLM, EnvironmentKey, 'Path', Copy(Paths, 2, Length(Paths) - 2));
-end;
-
-// True when every listed component has been downloaded already (EngineInstaller writes the marker last).
-function IsEngineInstalled(const MarkerFolders: String): Boolean;
-var
- Rest, Folder: String;
- Comma: Integer;
-begin
- Result := True;
- Rest := MarkerFolders;
- while Rest <> '' do
- begin
- Comma := Pos(',', Rest);
- if Comma = 0 then
- begin
- Folder := Rest;
- Rest := '';
- end
- else
- begin
- Folder := Copy(Rest, 1, Comma - 1);
- Rest := Copy(Rest, Comma + 1, MaxInt);
- end;
- if not FileExists(ExpandConstant('{localappdata}\Filee\engines\') + Folder + '\' + EngineMarker) then
- begin
- Result := False;
- Exit;
- end;
- end;
-end;
-
-// Called by AddEngines (generated) for every package of Settings > Engines.
-procedure AddEngine(const Id, MarkerFolders, DownloadSize, InstalledSize: String; Suggested: Boolean);
-var
- Index: Integer;
- Installed: Boolean;
-begin
- Installed := IsEngineInstalled(MarkerFolders);
- Index := EnginePage.Add(CustomMessage('Engine_' + Id));
- SetArrayLength(EngineIds, Index + 1);
- if Installed then
- begin
- EngineIds[Index] := '';
- EnginePage.CheckListBox.ItemSubItem[Index] := CustomMessage('EngineInstalled');
- EnginePage.CheckListBox.ItemEnabled[Index] := False;
- end
- else
- begin
- EngineIds[Index] := Id;
- EnginePage.CheckListBox.ItemSubItem[Index] := FmtMessage(CustomMessage('EngineSizes'), [DownloadSize, InstalledSize]);
- EnginePage.Values[Index] := Suggested;
- end;
-end;
-
-#include "obj\engines.iss"
-
-function SelectedEngines: String;
-var
- I: Integer;
-begin
- Result := '';
- for I := 0 to GetArrayLength(EngineIds) - 1 do
- if (EngineIds[I] <> '') and EnginePage.Values[I] then
- begin
- if Result <> '' then
- Result := Result + ',';
- Result := Result + EngineIds[I];
- end;
-end;
-
-function OnOff(Value: Boolean): String;
-begin
- if Value then
- Result := 'on'
- else
- Result := 'off';
-end;
-
-// Starts Filee as the signed-in user (not elevated) with the choices made in the wizard. An update starts it in
-// the tray, as it was running before.
-procedure StartFilee;
-var
- Parameters: String;
- ResultCode: Integer;
-begin
- if WasInstalled then
- Parameters := '--background'
- else
- Parameters := '--install-engines=' + SelectedEngines +
- ' --start-with-windows=' + OnOff(WizardIsTaskSelected('startup')) +
- ' --context-menu=' + OnOff(WizardIsTaskSelected('contextmenu'));
- if not ExecAsOriginalUser(ExpandConstant('{app}\{#AppExe}'), Parameters, '', SW_SHOWNORMAL, ewNoWait, ResultCode) then
- Log('Could not start Filee: ' + SysErrorMessage(ResultCode));
-end;
-
-function InitializeSetup: Boolean;
-begin
- WasInstalled := RegKeyExists(HKA, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{' + '{#AppGuid}' + '}_is1');
- HadVelopackInstall := FileExists(ExpandConstant('{localappdata}\Filee\Update.exe'))
- and DirExists(ExpandConstant('{localappdata}\Filee\current'));
- ExplorerMenuWasRegistered := IsExplorerMenuSupported and IsExplorerMenuRegistered;
- // (A line must not start with "[" in [Code]: the compiler would take it for a section.)
- Log(Format('Update: %d, Velopack install: %d, Explorer menu registered: %d', [Ord(WasInstalled),
- Ord(HadVelopackInstall), Ord(ExplorerMenuWasRegistered)]));
- Result := True;
-end;
-
-procedure InitializeWizard;
-begin
- EnginePage := CreateInputOptionPage(wpSelectTasks, CustomMessage('EnginesTitle'), CustomMessage('EnginesNote'),
- CustomMessage('EnginesDescription'), False, False);
- AddEngines;
-end;
-
-// True when at least one engine package is not installed yet.
-function AnyEngineOffered: Boolean;
-var
- I: Integer;
-begin
- Result := False;
- for I := 0 to GetArrayLength(EngineIds) - 1 do
- if EngineIds[I] <> '' then
- Result := True;
-end;
-
-function ShouldSkipPage(PageID: Integer): Boolean;
-begin
- // Updates keep the engines; Settings > Engines manages them from then on.
- Result := (PageID = EnginePage.ID) and (WasInstalled or not AnyEngineOffered);
-end;
-
-function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo,
- MemoGroupInfo, MemoTasksInfo: String): String;
-var
- Engines: String;
- I: Integer;
-begin
- Result := MemoDirInfo;
- if MemoTasksInfo <> '' then
- Result := Result + NewLine + NewLine + MemoTasksInfo;
- if WasInstalled then
- Exit;
- Engines := '';
- for I := 0 to GetArrayLength(EngineIds) - 1 do
- if (EngineIds[I] <> '') and EnginePage.Values[I] then
- Engines := Engines + Space + CustomMessage('Engine_' + EngineIds[I]) + NewLine;
- if Engines <> '' then
- Result := Result + NewLine + NewLine + CustomMessage('ReadyEngines') + NewLine + Engines;
-end;
-
-function PrepareToInstall(var NeedsRestart: Boolean): String;
-var
- ResultCode: Integer;
-begin
- Result := '';
- // Filee 1.2 and later exit when asked (after saving); this waits until they have.
- ResultCode := 0;
- if WasInstalled and FileExists(ExpandConstant('{app}\{#AppExe}')) then
- Exec(ExpandConstant('{app}\{#AppExe}'), '--quit', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
- // Filee 1.1 and earlier, or a Filee that did not answer: end it.
- if HadVelopackInstall or (ResultCode <> 0) then
- Exec(ExpandConstant('{sys}\taskkill.exe'), '/F /IM {#AppExe} /FI "USERNAME eq ' + GetUserNameString + '"', '',
- SW_HIDE, ewWaitUntilTerminated, ResultCode);
-end;
-
-procedure CurStepChanged(CurStep: TSetupStep);
-begin
- case CurStep of
- ssInstall:
- begin
- MoveLoadedDllAside(ExpandConstant('{app}'));
- if HadVelopackInstall then
- RemoveVelopackInstall;
- end;
- ssPostInstall:
- begin
- UpdateExplorerMenu;
- if WizardIsTaskSelected('cli') then
- AddCliToPath;
- StartFilee;
- end;
- end;
-end;
-
-procedure CurPageChanged(CurPageID: Integer);
-begin
- if CurPageID = wpFinished then
- begin
- WizardForm.FinishedLabel.Caption := CustomMessage('FinishedRunning');
- if not WasInstalled and (SelectedEngines <> '') then
- WizardForm.FinishedLabel.Caption := WizardForm.FinishedLabel.Caption + #13#10#13#10 + CustomMessage('FinishedEngines');
- WizardForm.AdjustLabelHeight(WizardForm.FinishedLabel);
- end;
-end;
-
-procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
-begin
- case CurUninstallStep of
- // Before files are removed: out of the install folder, so that it can be deleted.
- usUninstall:
- MoveLoadedDllAside(ExpandConstant('{tmp}'));
- usPostUninstall:
- begin
- RemoveCliFromPath;
- if DirExists(ExpandConstant('{app}')) and not RemoveDir(ExpandConstant('{app}')) then
- RestartReplace(ExpandConstant('{app}'), '');
- end;
- end;
-end;
diff --git a/installer/wizard-dark.png b/installer/wizard-dark.png
deleted file mode 100644
index 6c9f122a..00000000
Binary files a/installer/wizard-dark.png and /dev/null differ
diff --git a/installer/wizard-light.png b/installer/wizard-light.png
deleted file mode 100644
index 5aafddf1..00000000
Binary files a/installer/wizard-light.png and /dev/null differ