Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
f196a1c
Add unit test project and CI build
lumenpearson Oct 22, 2026
c29d7b6
Fix GoodCheck success ratio calculation
lumenpearson Oct 22, 2026
cf96261
Keep NoDPI --quiet flag separated from other arguments
lumenpearson Oct 22, 2026
9c4c1db
Report running third-party DPI processes in basic diagnostics
lumenpearson Oct 22, 2026
8ad3581
Preserve quotes in imported batch variable values
lumenpearson Oct 22, 2026
0864c1f
Merge localization files without duplicate key errors on pack export
lumenpearson Oct 22, 2026
76ddd0c
Handle store items without dependencies
lumenpearson Oct 22, 2026
9786dde
Store installed version and link for online store items
lumenpearson Oct 22, 2026
a9d092e
Keep HTTP status code in download error result
lumenpearson Oct 22, 2026
ffc88e1
Treat .MSI extension case-insensitively and handle restart-initiated …
lumenpearson Oct 22, 2026
ac5735f
Restore tray component controls after GoodCheck finishes
lumenpearson Oct 22, 2026
d206830
Validate archive entry paths before extraction
lumenpearson Oct 22, 2026
8bf30e7
Validate update package entry paths before applying
lumenpearson Oct 22, 2026
04da03c
Escape pipe message values
lumenpearson Oct 22, 2026
67abc7f
Prevent duplicate tasks for the same component
lumenpearson Oct 22, 2026
b5cbbf5
Rebuild tray component list in a single UI pass
lumenpearson Oct 22, 2026
d71de58
Make settings persistence culture-independent and retry busy writes
lumenpearson Oct 22, 2026
a6ababa
Do not throw from tray error handlers
lumenpearson Oct 22, 2026
fd625e0
Restore proxy configuration when a component is restarted
lumenpearson Oct 22, 2026
40c4bad
Restore the previous system proxy settings when the component stops
lumenpearson Oct 22, 2026
6815d95
Stop components when the tray exits or the session ends
lumenpearson Oct 22, 2026
0a45b6d
Wait for a running tray process before starting a new one
lumenpearson Oct 22, 2026
d6c85cf
Ignore broken pipe errors while disposing the pipe
lumenpearson Oct 22, 2026
74586cf
Rebuild converted Zapret2 command lines after an application update
lumenpearson Oct 22, 2026
08119cb
Fix system proxy page crash when no proxy is configured
lumenpearson Oct 22, 2026
4056575
Keep the preset editor open until unsaved changes are confirmed
lumenpearson Oct 22, 2026
9acd4fc
Do not crash on store items without version bounds
lumenpearson Oct 22, 2026
8aa911b
Install every selected kit in the welcome wizard
lumenpearson Oct 22, 2026
6dd1d5a
Stop after a failed preset save
lumenpearson Oct 22, 2026
10dae1f
Fix default filters in file dialogs
lumenpearson Oct 22, 2026
2d33ed1
Show the selected Mica Smoke editor background in the menu
lumenpearson Oct 22, 2026
d531db4
Fix dependency property registrations
lumenpearson Oct 22, 2026
9867919
Count temporary files in the storage usage view
lumenpearson Oct 22, 2026
0b200f5
Save the new value of the monospace-only font option
lumenpearson Oct 22, 2026
907ef2a
Do not save window geometry while the window is minimized
lumenpearson Oct 22, 2026
d6549e9
Report MSI fatal error 1603 as a failed installation
lumenpearson Oct 22, 2026
fd0b1ea
Synchronize settings reads with writes
lumenpearson Oct 22, 2026
fe36066
Restrict the tray pipe to the application UI
lumenpearson Oct 22, 2026
a87b90a
Restore nuget.org as a package source for the GUI project
lumenpearson Oct 23, 2026
d13acdf
Preserve hosts file encoding and write it atomically
lumenpearson Oct 23, 2026
0578bb6
Stage updates and roll back replaced files on failure
lumenpearson Oct 23, 2026
4e2b0b5
Build Update and EditHostFile in CI
lumenpearson Oct 23, 2026
e0e7071
Handle unhandled exceptions in the GUI
lumenpearson Oct 23, 2026
2c1ba58
Save two Windows-1252 source files as UTF-8
lumenpearson Oct 23, 2026
63450ce
Unsubscribe GoodCheck pages from the process service
lumenpearson Oct 23, 2026
1ca25c9
Stop preset tests when they are cancelled or the window closes
lumenpearson Oct 23, 2026
3fe6ee5
Clean up running components, drivers and autorun on uninstall
lumenpearson Oct 23, 2026
9f67545
Build Update without strong naming in CI
lumenpearson Oct 23, 2026
91d699e
Show preset arguments before importing
lumenpearson Oct 23, 2026
ebe554b
Restrict paths the tray accepts from the UI
lumenpearson Oct 23, 2026
952edaa
Accept the desktop user's data directory in the tray path check
lumenpearson Oct 23, 2026
63e7a09
Keep later hosts file changes when recovering
lumenpearson Oct 23, 2026
5d31bdd
Remove the hosts block and runtime files on uninstall, link the MSI v…
lumenpearson Oct 23, 2026
779e10e
Close the tray gracefully before updating and remove dropped files
lumenpearson Oct 23, 2026
7edc97c
Map Win32, socket and HTTP errors to their codes
lumenpearson Oct 23, 2026
376ed7f
Save conditional tasks atomically and skip duplicate task ids
lumenpearson Oct 23, 2026
dc085c5
Make temporary names unique and do not copy a file onto itself
lumenpearson Oct 23, 2026
5bafb69
Read the desktop user's settings in a tray elevated with another account
lumenpearson Oct 23, 2026
7521f30
Verify the catalog signature instead of only reading its certificate
lumenpearson Oct 23, 2026
0a93c11
Check update and installer packages in the tray before running them
lumenpearson Oct 23, 2026
4b77021
Do not let the elevated tray run user-chosen programs
lumenpearson Oct 23, 2026
a90a1c1
Keep tray task directory and settings parsing inside safe limits
lumenpearson Oct 23, 2026
0acfe15
Fall back to the template log level instead of debug logging
lumenpearson Oct 23, 2026
b922dde
Retry pipe creation instead of exiting when another process holds the…
lumenpearson Oct 23, 2026
af00a87
Give a custom installation directory the rights of Program Files
lumenpearson Oct 23, 2026
bd0f647
Keep unsigned packs from bringing programs and install actions
lumenpearson Oct 23, 2026
b385a4f
Validate store item ids and accept only HTTPS store downloads
lumenpearson Oct 23, 2026
4668ee1
Check signed archives before their files reach the destination
lumenpearson Oct 23, 2026
9f42050
Merge settings changes with the file instead of overwriting it
lumenpearson Oct 23, 2026
30a477e
Await MSI installs from item scripts and harden script parsing
lumenpearson Oct 23, 2026
c271d65
Send long pipe messages whole and keep the auth GUID out of logs
lumenpearson Oct 23, 2026
574ad00
Do not block the UI thread on task lookups and fix SendTaskData
lumenpearson Oct 23, 2026
e013113
Keep list settings items that contain the separator
lumenpearson Oct 23, 2026
e9f51e8
Save presets atomically without breaking the cached name
lumenpearson Oct 23, 2026
12ba653
Read batch files in their code page and match commands in any case
lumenpearson Oct 23, 2026
241b0ee
Merge domain lists by whole lines
lumenpearson Oct 23, 2026
be3e6ca
Compare release tags with the version helper
lumenpearson Oct 23, 2026
363c4e8
Keep whole arguments when removing proxy address arguments
lumenpearson Oct 23, 2026
312979b
Do not treat apostrophes as quotes in preset command lines
lumenpearson Oct 23, 2026
a4800c7
Share HTTP clients between store requests
lumenpearson Oct 23, 2026
0475a07
Rotate log files and never fall back to the working directory
lumenpearson Oct 23, 2026
587cc1d
Queue content dialogs per window
lumenpearson Oct 23, 2026
798bb3b
Restore the component after a preset test
lumenpearson Oct 23, 2026
cd397f2
Make GoodCheck service notifications events
lumenpearson Oct 23, 2026
fafed28
Fix the timestamps check and run troubleshooting tools without blocking
lumenpearson Oct 23, 2026
d6d0cbe
Unsubscribe pages from store and update events when they unload
lumenpearson Oct 23, 2026
fbb6b3a
Fix two missing resource keys
lumenpearson Oct 23, 2026
1170436
Use existing resource keys for two loading texts
lumenpearson Oct 23, 2026
1c7817c
Localize the critical error window and the GoodCheck DoH header
lumenpearson Oct 23, 2026
564052d
Localize file dialog titles and filters
lumenpearson Oct 23, 2026
9e5e484
Give icon-only buttons accessible names and fix tooltip resource keys
lumenpearson Oct 23, 2026
a1685a4
Stop the selection once when the user confirms closing
lumenpearson Oct 23, 2026
3ccf7c6
Parse batch escapes, %% and path modifiers like cmd in preset import
lumenpearson Oct 23, 2026
34a0422
Import System for the WinRT awaiter in ContentDialogQueue
lumenpearson Oct 23, 2026
691e81e
Build the release layout, MSI and patches from a clean checkout
lumenpearson Oct 23, 2026
26c90ba
Fix the build notes in CONTRIBUTING and list third-party licenses
lumenpearson Oct 23, 2026
d634628
Remove unused packages and check the installer file list
lumenpearson Oct 23, 2026
3f00d61
Find GoodCheck through the Store database and tell a broken install f…
lumenpearson Oct 23, 2026
56be5f4
Ask before a proxy component listens on a network address
lumenpearson Oct 23, 2026
340b6b6
Restart running components after a component update in order
lumenpearson Oct 23, 2026
e901e71
Create windows only after the localizer is ready and fall back to a k…
lumenpearson Oct 23, 2026
72c8cba
Survive damaged pack, ProxiFyre and settings files
lumenpearson Oct 23, 2026
20b360b
Install the PKCS library with the MSI and keep the file list in sync
lumenpearson Oct 23, 2026
1cd5e23
Stop a component before its files are replaced or deleted
lumenpearson Oct 23, 2026
f31bb22
Stop writing the unknown apply_config command into preset packs
lumenpearson Oct 23, 2026
1b0fbe1
Wait for the network before restarting components after resume
lumenpearson Oct 23, 2026
e5f4fa6
Keep the Store cache until a new one is extracted and fall back to Gi…
lumenpearson Oct 23, 2026
ab56f0b
Accept only public routes in cdpiui:// links from outside the applica…
lumenpearson Oct 23, 2026
5dc48d3
Do not leave a second instance hanging when the activation redirect f…
lumenpearson Oct 23, 2026
1fb1abf
Keep activation arguments when the GUI has to start the tray first
lumenpearson Oct 23, 2026
1f325e6
Let only the latest settings tile build fill the component page
lumenpearson Oct 23, 2026
955a916
Update the accent preview on the UI thread
lumenpearson Oct 23, 2026
ec240b0
Rank failed handshakes as failures in the preset test and fix remaini…
lumenpearson Oct 23, 2026
e5a7f53
Register file associations again when the application path changes
lumenpearson Oct 23, 2026
b580d5a
Build the GUI for x64 only
lumenpearson Oct 23, 2026
2f7ae6d
Read and write GoodCheck config.ini safely
lumenpearson Oct 23, 2026
d3bfced
Rewrite only whole paths and keep user choices in the GoodbyeDPI-UI i…
lumenpearson Oct 23, 2026
9b9f1db
Fall back to a known language, skip UI updates of closed windows, dro…
lumenpearson Oct 23, 2026
dbb17e9
Compare the saved window size with the work area in the same units
lumenpearson Oct 23, 2026
47e0ca8
Keep the installed version when an update fails
lumenpearson Oct 23, 2026
456ae7c
Create file links without losing the original file
lumenpearson Oct 23, 2026
2d0bb2f
Finish the Store update check on every path and skip items without a …
lumenpearson Oct 23, 2026
6f0dbbe
Guard every access to the Store queue with one lock
lumenpearson Oct 23, 2026
ea4b626
Remove an installer that failed to install
lumenpearson Oct 23, 2026
4d8be0d
Stop a download whose body stalls and check free disk space first
lumenpearson Oct 23, 2026
cd76edb
Time out and cancel MSI installations of Store items
lumenpearson Oct 23, 2026
8005ea1
Validate item dependencies and the database write during installation
lumenpearson Oct 23, 2026
76ddabe
Compare release candidates, short versions and tagged versions correctly
lumenpearson Oct 23, 2026
dddf785
Read item rows with NULL columns and check item paths with a separator
lumenpearson Oct 23, 2026
54105aa
End the application update check in the UI also when it fails
lumenpearson Oct 23, 2026
db93d21
Use the page dispatcher for update events on the About page
lumenpearson Oct 23, 2026
4773bff
Skip a damaged category or item of the Store catalog instead of all o…
lumenpearson Oct 23, 2026
ca8e508
Take the preview icon of a local pack only from the pack
lumenpearson Oct 23, 2026
73c2f2e
Convert old zapret1 strategy names and drop packet tuning options wit…
lumenpearson Oct 23, 2026
2fb8b0e
Convert a legacy Zapret preset again when the converter or the comman…
lumenpearson Oct 23, 2026
0085752
Expand preset variables at start the same way as in the editor
lumenpearson Oct 23, 2026
443f9c4
Replace preset file paths as whole paths and quote store folders with…
lumenpearson Oct 23, 2026
bee06db
Read start lines, quoted set names and all !VAR! references in preset…
lumenpearson Oct 23, 2026
b45068d
Report failed preset pack exports and keep copies inside the pack
lumenpearson Oct 23, 2026
f90870b
Keep searching other items when one item folder of the autocorrection…
lumenpearson Oct 23, 2026
d356311
Find blob files with an offset, Lua files with ';' in the name and ne…
lumenpearson Oct 23, 2026
55f1a64
Replace the component helper list atomically
lumenpearson Oct 23, 2026
21bdd48
Refuse to start a component without executable or startup parameters
lumenpearson Oct 23, 2026
8432da5
Install only .msi files from an MSI folder of a pack
lumenpearson Oct 23, 2026
2f55a7b
Fix small parsing errors in presets: --new, $ in names, @ in paths
lumenpearson Oct 23, 2026
7dd2a8f
Restore the system proxy of the user after a crash and write it to th…
lumenpearson Oct 23, 2026
294fcc2
Keep the tray alive when a task event reaches a closing menu
lumenpearson Oct 23, 2026
37b53c3
Close the open tray menu before showing a new one
lumenpearson Oct 23, 2026
5cf0ae7
Tie components to the tray and fix process start and output handling …
lumenpearson Oct 23, 2026
ec34bf1
Allow only one tray per machine
lumenpearson Oct 23, 2026
2fa5486
Send component data only to an authorized pipe client and drop idle c…
lumenpearson Oct 23, 2026
68ab1b5
Keep conditional launch triggers working across task folder changes
lumenpearson Oct 23, 2026
a771aa5
Stop Zapret2 before removing the WinDivert service and log sc failures
lumenpearson Oct 23, 2026
5cda9db
Unblock the tray buttons and close the job when GoodCheck cannot start
lumenpearson Oct 23, 2026
cc68ca5
Open the GUI from the tray icon with the keyboard and stop forcing co…
lumenpearson Oct 23, 2026
85ba498
Read the whole GoodCheck log of a run and treat an early exit as failure
lumenpearson Oct 23, 2026
d04fcd5
Refuse shared presets and BlockCheck2 reports that make the component…
lumenpearson Oct 23, 2026
c8e0b53
Write GoodCheck site lists without BOM, keep same-named lists apart, …
lumenpearson Oct 23, 2026
6a34a74
Do not count provider block pages as working routes in BlockCheck2
lumenpearson Oct 23, 2026
6ae85f6
Stop a BlockCheck2 scan when strategies keep failing to start
lumenpearson Oct 23, 2026
b2931fa
Make the troubleshooting checks match the services they look for
lumenpearson Oct 23, 2026
1c7cc56
Give up waiting for the tray answer to a folder access fix after 30 s…
lumenpearson Oct 23, 2026
cbb9f0c
Reject shared presets with extremely compressed entries
lumenpearson Oct 23, 2026
b7a67a7
Accept comment lines in GoodCheck site lists, pass only a number of p…
lumenpearson Oct 23, 2026
54ca939
Keep only English and Russian .mui files in the release layout and up…
lumenpearson Oct 23, 2026
d317778
Ignore clicks on a disabled tray button
lumenpearson Oct 23, 2026
7636d4c
Report Store installation exceptions and keep failed updates in the u…
lumenpearson Oct 23, 2026
2d9d4f9
Save Store items with missing optional fields to the database
lumenpearson Oct 23, 2026
1b935de
Share presets that use --hostlist-auto before their first run
lumenpearson Oct 23, 2026
ebc5f50
Keep only the last part of the component output in memory
lumenpearson Oct 23, 2026
456f3f3
Skip the group marker in GetKeyPair and generate random hex values wi…
lumenpearson Oct 23, 2026
e691a4a
Keep BlockCheck2 site lists atomic in synthesis and lower report impo…
lumenpearson Oct 23, 2026
e9af308
Fix page-level defects: test runs left running, UI calls from pool th…
lumenpearson Oct 23, 2026
66e7d09
Fix control and helper defects: cached command parameters, shared def…
lumenpearson Oct 23, 2026
9e47d12
Start the update after the form is shown
lumenpearson Oct 23, 2026
3de9f91
Fix low-priority tray and core defects: ANSI cleanup cutting text, ho…
lumenpearson Oct 23, 2026
bb5362d
Fix low-priority add-on defects: @rem comments, tokenizing quoted fol…
lumenpearson Oct 23, 2026
c053223
Fix BlockCheck2 low-priority defects: trailing newline in validated n…
lumenpearson Oct 23, 2026
86a9f80
Fix low-priority GUI defects: remaining-time minutes, disks compared …
lumenpearson Oct 23, 2026
824bb1f
Do not start the GUI elevated or after a silent install, require Powe…
lumenpearson Oct 23, 2026
3c1558c
Fix misspelled identifiers
lumenpearson Oct 23, 2026
486e253
Correct the README and rewrite CONTRIBUTING to match the current buil…
lumenpearson Oct 23, 2026
643de01
Rewrite CONTRIBUTING in ASD-STE100 Simplified Technical English
lumenpearson Oct 23, 2026
3a0ffd3
Add first drafts of the updater, hosts editor, installer and CI docum…
lumenpearson Oct 23, 2026
ad23771
Keep files that a patch does not change and trust the catalog certifi…
lumenpearson Oct 23, 2026
babff5a
Harden pipe authorization and detect MSI installations at run time
lumenpearson Oct 23, 2026
82fb1fc
Fix tray messages to a closed GUI, per-component output requests, upd…
lumenpearson Oct 23, 2026
17e78d1
Treat a missing hosts file as empty in EditHostFile
lumenpearson Oct 23, 2026
af26319
Rewrite the English help in ASD-STE100 and complete the help articles
lumenpearson Oct 23, 2026
b320a0c
Fix help navigation and window creation during start-up
lumenpearson Oct 23, 2026
66faab6
Fix nested scripts in LScript conditions and quote folder variables
lumenpearson Oct 23, 2026
9fdfa54
Fix local pack icons, pack file search and install action arguments
lumenpearson Oct 23, 2026
86b0941
Document the add-ons in ASD-STE100
lumenpearson Oct 23, 2026
b681cc2
Fix add-on defects found while documenting them
lumenpearson Oct 23, 2026
3030eec
Remove the unused installer version property and map untrusted certif…
lumenpearson Oct 23, 2026
ec870c8
Update the add-on documents for the latest add-on fixes
lumenpearson Oct 23, 2026
b209ea9
Add the project documents for the GUI, Core, LScript, Shared, the pip…
lumenpearson Oct 23, 2026
0c86473
Bring the project documents in line with the current code and ASD-STE100
lumenpearson Oct 23, 2026
c773687
Keep the pipe secret stable between releases and fix updater and patc…
lumenpearson Oct 23, 2026
11bddc5
Remove references to an external review document from code comments
lumenpearson Oct 23, 2026
e5fe52f
Compare the pipe secret in constant time and remove project entries f…
lumenpearson Oct 23, 2026
620b8df
Add new help pages to the MSI file list
lumenpearson Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
329 changes: 168 additions & 161 deletions .github/CONTRIBUTING.md

Large diffs are not rendered by default.

232 changes: 232 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# CI and releases

The workflows are in `.github/workflows`. The scripts that they run are in `.github/scripts`.
All jobs run on `windows-latest`. [CONTRIBUTING.md](CONTRIBUTING.md) tells how to build locally.

## CI (`workflows/ci.yml`)

CI runs on pushes to `main`, `dev` and `fix/**`, and on pull requests. It has read-only
`contents` permission. A new run for the same ref cancels the current run.

| Job | Steps |
|-----|-------|
| `libraries` | Installs the .NET 8 SDK. Runs `create_secret_stub.ps1`. Builds `CDPIUI.Shared`, `CDPIUI.Core` (x64), `CDPIUI.AddOns` and `CDPIUI.TrayIcon` (x64) in Release. Runs `dotnet test CDPIUI.Tests`. |
| `gui` | Runs `build_portable.ps1` and `check_setup_files.ps1`. Builds the MSI. Uploads `NewSetup/bin/**/*.msi` as the `setup-msi` artifact for 7 days. |
| `tools` | Builds `Update/Update.csproj` (with packages.config restore) and `EditHostFile/EditHostFile.csproj` in Release with `msbuild`. |

The `gui` job has `continue-on-error`. The WinUI build needs the CommunityToolkit Labs feed and
the Windows App SDK tools. The job gives only information until the build is reproducible on
hosted runners.

## Release files (`workflows/build_and_patch.yml`)

A user starts this workflow manually (`workflow_dispatch`).

### Inputs

| Input | Default | Meaning |
|-------|---------|---------|
| `version` | empty | The version for `requirements.json`. If empty, the workflow uses the first `FileVersion` in `CDPIUI/CDPIUI.csproj`. The value must match `^\d+(\.\d+){1,3}$`. |
| `previous_repository` | `Storik4pro/cdpiui` | The repository whose release contains the previous `_portable.zip`. |
| `previous_tag` | empty | The release tag of the previous `_portable.zip`. If empty, the workflow uses the latest release. With `none`, the workflow makes a full patch. |
| `patch_urls` | empty | Patches that the application must install first, separated by spaces. The workflow writes them to `patch_urls`. |

### Secrets

| Secret | Use |
|--------|-----|
| `STORE_GITHUB_TOKEN`, `STORE_GITLAB_TOKEN` | The Store tokens in `Secret.cs` (`GitHubToken`, `GitLabToken`). |
| `STORE_PROXY_URL`, `STORE_PROXY_KEY` | The Store reverse proxy in `Secret.cs` (`ProxyURL`, `ProxyKey`). |
| `TRUSTED_CERTIFICATES` | The SHA-1 thumbprints for `Secret.TrustedCertificates`, separated by spaces, commas or semicolons. |
| `PIPE_AUTH_GUID` | The pipe secret `Secret.AuthGuid`. Keep the same value for all releases. |
| `CATALOG_CERTIFICATE_PFX_BASE64` | The PFX file of the catalog signature certificate, in Base64. The patch step writes it to `RUNNER_TEMP\catalog.pfx` and deletes it after the step. |
| `CATALOG_CERTIFICATE_PASSWORD` | The password of the PFX file. |

All secrets are optional for the workflow. The "Create Secret.cs" step gives them to
`create_release_secret.ps1` as environment variables. The PFX goes in `CATALOG_CERTIFICATE`.

WARNING: Set `CATALOG_CERTIFICATE_PFX_BASE64` and `CATALOG_CERTIFICATE_PASSWORD` before you make a
release. Without the certificate, the catalogs have no signature and the application rejects the
patch.

WARNING: Make sure that `TrustedCertificates` is not empty in a release build. Set
`TRUSTED_CERTIFICATES`, or set the catalog certificate. With an empty list, the release build
rejects all signed catalogs, also its own patches.

### Steps

1. Write `CDPIUI.Shared/Secrets/Secret.cs` with `create_release_secret.ps1 -Force` (step "Create Secret.cs").
2. Build the portable layout (`build_portable.ps1`). The script keeps the `Secret.cs` file of step 1.
3. Check the installer file list (`check_setup_files.ps1`).
4. Build the MSI.
5. Find the version.
6. Download the previous `_portable.zip` with `gh release download`. The workflow skips this step if `previous_tag` is `none`.
7. Make the patch with `make_patch.ps1`.
8. Make the portable archive:
1. Copy the publish folder.
2. Change the name of `Update.exe` to `_Update.exe`.
3. Make a `catalog.cat` (version 2.0) of the full folder.
4. Sign the catalog if the certificate is available. If the signature has no signer certificate, the step fails.
5. Put the catalog in the folder and make the ZIP file.

### Output

The workflow makes the artifact `release-<version>`. It contains these files:

- `<version>_patch.cdpipatch`
- `_portable.zip`
- `Setup.msi`

The workflow does not make a GitHub release.

## Scripts (`scripts/`)

### `build_portable.ps1`

Parameter: `-Configuration` (default `Release`). The script requires `msbuild` and the .NET 8 SDK.
The script does these steps:

1. Run `create_secret_stub.ps1`.
2. Delete the old publish folder `CDPIUI/bin/x64/<Configuration>/net8.0-windows10.0.22621.0/publish`.
3. Publish `CDPIUI/CDPIUI.csproj` to that folder (x64, `win-x64`, framework-dependent).
4. Remove the language folders that contain only `.mui` files, except `en-us` and `ru-ru`. The Windows App SDK copies approximately 90 languages.
5. Publish `CDPIUI.TrayIcon` as a single file to `artifacts/tools/tray`.
6. Build `Update` (x64) and `EditHostFile`.
7. Copy `CDPIUI_TrayIcon.exe`, `Update.exe` and `EditHostFile.exe` into the publish folder.

### `check_setup_files.ps1`

This script has no parameters. It compares two lists without case sensitivity:

- the files in the Release publish folder, without `*.pdb` files;
- the `Source="$(var.SourceDir)\..."` entries in `NewSetup/NewSetupFiles.wxs`.

The script fails if a file is missing from one of the lists.
[NewSetup/README.md](../NewSetup/README.md) gives the file list rule.

### `create_secret_stub.ps1`

This script has no parameters. Git ignores `CDPIUI.Shared/Secrets/Secret.cs`. The script does
these steps:

- If the file does not exist, the script writes a `Secret` class with empty tokens, an empty
`TrustedCertificates` list and a random `AuthGuid`. With this class, the solution compiles.
- If the file exists and its `AuthGuid` is empty, the script writes a random `AuthGuid` into it.
- The script does not change other values of an existing file.

The pipe rejects all clients when `AuthGuid` is empty. Thus the stub must have a value.

### `create_release_secret.ps1`

The release workflow runs this script. It writes `Secret.cs` from these environment variables:

| Variable | Member |
|----------|--------|
| `STORE_GITHUB_TOKEN`, `STORE_GITLAB_TOKEN` | `GitHubToken`, `GitLabToken` |
| `STORE_PROXY_URL`, `STORE_PROXY_KEY` | `ProxyURL`, `ProxyKey` |
| `TRUSTED_CERTIFICATES` | `TrustedCertificates` |
| `CATALOG_CERTIFICATE`, `CATALOG_CERTIFICATE_PASSWORD` | `TrustedCertificates`, if `TRUSTED_CERTIFICATES` gives no thumbprint |
| `PIPE_AUTH_GUID` | `AuthGuid` |

Rules:

- The script keeps only thumbprints with 40 hexadecimal characters, in upper case.
- If `TRUSTED_CERTIFICATES` gives no thumbprint, the script uses the thumbprint of the PFX in `CATALOG_CERTIFICATE`.
- If there is no thumbprint, the script shows a warning. The build then rejects signed packages and patches.
- `AuthGuid` comes from `PIPE_AUTH_GUID`. Without it, the script derives the value from `CATALOG_CERTIFICATE` (SHA-256). Without both, the value is random and the script shows a warning.
- `AuthGuid` must stay the same from build to build. A new value changes `CDPIUI.Shared.dll` and the tray, and every patch then contains them.
- If `Secret.cs` exists, the script does not change it. With `-Force`, the script replaces it.

### `make_patch.ps1`

The script requires PowerShell 7. Windows PowerShell 5.1 can write `\` in ZIP entry names, and
the updater does not read these names as folders.

| Parameter | Required | Meaning |
|-----------|----------|---------|
| `-CurrentDir` | Yes | The publish folder of the new build. |
| `-PreviousZip` | No | The previous `_portable.zip`. If empty, the patch contains all files. |
| `-Version` | Yes | The version for `requirements.json`, from `1.2` to `1.2.3.4`. |
| `-PatchUrls` | No | The `patch_urls` for `requirements.json`. |
| `-OutPatch` | No | The output file. The default is `patch.cdpipatch`. |
| `-CertificatePath`, `-CertificatePassword` | No | The PFX file that signs the catalog, and its password. |
| `-TimestampServer` | No | The timestamp server for `Set-AuthenticodeSignature`. The workflow does not use it. |

Rules:

- The patch contains a file if the previous build does not have it, or if its SHA-256 hash is different.
- The script ignores `catalog.cat` in the current folder.
- The script stores and compares `Update.exe` as `_Update.exe`.
- The script fails if no file changed.
- The script fails if the signature step fails.
- The script fails if `Test-FileCatalog` does not return `Valid` for the new catalog.

## `.cdpipatch` format

A `.cdpipatch` file is a ZIP archive with this structure:

```
requirements.json {"patch_urls": [...], "version": "x.y.z.w"}
CDPIUI/catalog.cat signed catalog (version 2.0) of all other files in CDPIUI/
CDPIUI/... the changed files, at their installed paths
```

`make_patch.ps1` writes `requirements.json` in UTF-8 without BOM. The application reads it into
`PatchRequirementsModel` (`CDPIUI.Core/Store/Application/PatchRequirementsModel.cs`).

## How the application applies a patch

### GUI side

`CDPIUI.Core/Store/Application/ApplicationUpdateService.cs` prepares the patch. For a portable
installation (`State.IsApplicationBuildAsSingleFile`), the Store puts the patch at
`<Store items>/<application id>/patch.cdpipatch`. `GetPatchReadyToInstall` then does these steps:

1. Extract the patch to `Patches\<patch file name without extension>` in the same folder.
2. Read `requirements.json`. An empty `version` causes an error.
3. Reject the patch if the installed version is the same or newer.
4. Verify `CDPIUI/catalog.cat` against the `CDPIUI/` folder.
5. Process each entry of `patch_urls`. The service skips empty entries.
1. Download the required patch to `required/<index>` in the patch folder. The index is 0 for the first entry, 1 for the next entry, and so on.
2. Extract the full archive.
3. Read the version from the `requirements.json` of the required patch. If the file or the version is not valid, the operation fails.
4. If the installed version is the same or newer, skip the required patch. Also skip it if its version is the same as or newer than the version of the main patch, because the main patch is always the last layer.
5. Verify the catalog of the `CDPIUI/` folder of the required patch.
6. Sort the required patches by version, the oldest first. The sequence in `patch_urls` is not important.
7. Write a new `patch.cdpipatch` with one layer for each patch (`layers/0/`, `layers/1/`, ...).
The main patch is the last layer. Each layer keeps its own `catalog.cat`.
8. Delete the `Patches` folder.

When the Store operation completes without errors, the GUI sends the `BeginApplicationUpdate`
message to the tray (`CDPIUI.Core/Features/ApplicationUpdate.cs`). For an MSI installation, the
file is `patch.msi`. The tray installs it with `msiexec /i ... /qn+`.

### Tray side

`CDPIUI.TrayIcon/Helper/Utils.cs` and `CDPIUI.TrayIcon/Helper/PackageStaging.cs` do these steps:

1. Check the path with `TrustedPaths.IsAllowed`.
2. Copy the file to `<install>\.staging\<GUID>\`. In a per-machine installation, only administrators can write to this folder. Thus nobody can replace the file between the check and the installation.
3. Extract the copy to `verify\`.
4. Verify the catalog of each `layers/*` folder. If there are no layers, verify the `CDPIUI/` folder.
5. If a check fails, stop and show the `UpdateFailure` notification.
6. Start `Update.exe --directory-to-zip "<staged file>" --destination-directory "<install>"`.

[Update/README.md](../Update/README.md) describes `Update.exe`. The tray deletes the `.staging`
folder at each start.

`Update.exe` does not copy a `catalog.cat` file from a patch into the installation folder. It also
does not remove files that are not in the patch, because a patch contains only the changed files.

### Catalog check

`CDPIUI.Shared/Security/CatalogVerifier.cs` checks a catalog with these rules:

- The catalog must be a CMS signed message with one or more signers.
- The SHA-1 thumbprint of each signer certificate must be in `Secret.TrustedCertificates`.
- The signature of each signer must be valid.
- The verifier does not build the certificate chain, because the certificates are pinned and self-signed.
- `Test-FileCatalog ... -FilesToSkip catalog.cat` must return `Valid` in a maximum of 2 minutes.

The verifier runs `Test-FileCatalog` in `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`.
It gives the paths through environment variables.
63 changes: 63 additions & 0 deletions .github/scripts/build_portable.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<#
.SYNOPSIS
Builds the x64 release layout of CDPI UI: the GUI publish folder with the tray, Update.exe and
EditHostFile.exe next to it. NewSetup/NewSetupFiles.wxs takes its files from the same folder.
Needs msbuild (Visual Studio or microsoft/setup-msbuild) and the .NET 8 SDK.
#>
param(
[string] $Configuration = "Release"
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$root = (Resolve-Path (Join-Path $PSScriptRoot "../..")).Path
$publish = Join-Path $root "CDPIUI/bin/x64/$Configuration/net8.0-windows10.0.22621.0/publish"
$tools = Join-Path $root "artifacts/tools"

function Invoke-Checked([string] $name, [scriptblock] $command) {
Write-Output "== $name"
& $command
if ($LASTEXITCODE -ne 0) { throw "$name failed with exit code $LASTEXITCODE" }
}

& (Join-Path $PSScriptRoot "create_secret_stub.ps1")

if (Test-Path -LiteralPath $publish) { Remove-Item -LiteralPath $publish -Recurse -Force }

Invoke-Checked "Publish CDPIUI" {
msbuild (Join-Path $root "CDPIUI/CDPIUI.csproj") /restore /t:Publish /m /nologo /v:minimal `
"/p:Configuration=$Configuration" /p:Platform=x64 /p:RuntimeIdentifier=win-x64 /p:SelfContained=false `
"/p:PublishDir=$publish\"
}

# The Windows App SDK copies its .mui files for about 90 languages regardless of
# SatelliteResourceLanguages; the application and the MSI have English and Russian only.
$keptLanguages = @("en-us", "ru-ru")
Get-ChildItem -LiteralPath $publish -Directory |
Where-Object { $keptLanguages -notcontains $_.Name.ToLowerInvariant() } |
Where-Object {
$files = @(Get-ChildItem -LiteralPath $_.FullName -File -Recurse)
$files.Count -gt 0 -and @($files | Where-Object { $_.Extension -ne ".mui" }).Count -eq 0
} |
Remove-Item -Recurse -Force

Invoke-Checked "Publish CDPIUI.TrayIcon" {
dotnet publish (Join-Path $root "CDPIUI.TrayIcon/CDPIUI.TrayIcon.csproj") -c $Configuration -p:Platform=x64 `
-r win-x64 --self-contained false -p:PublishSingleFile=true -o (Join-Path $tools "tray")
}

Invoke-Checked "Build Update" {
msbuild (Join-Path $root "Update/Update.csproj") /restore /p:RestorePackagesConfig=true /m /nologo /v:minimal `
"/p:SolutionDir=$root\" "/p:Configuration=$Configuration" /p:Platform=x64
}

Invoke-Checked "Build EditHostFile" {
msbuild (Join-Path $root "EditHostFile/EditHostFile.csproj") /m /nologo /v:minimal "/p:Configuration=$Configuration"
}

Copy-Item -LiteralPath (Join-Path $tools "tray/CDPIUI_TrayIcon.exe") -Destination $publish
Copy-Item -LiteralPath (Join-Path $root "Update/bin/x64/$Configuration/Update.exe") -Destination $publish
Copy-Item -LiteralPath (Join-Path $root "EditHostFile/bin/$Configuration/EditHostFile.exe") -Destination $publish

Write-Output "Portable layout: $publish"
26 changes: 26 additions & 0 deletions .github/scripts/check_setup_files.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<#
.SYNOPSIS
Compares the publish folder with the file list of NewSetup/NewSetupFiles.wxs. WiX fails on
listed files that are missing, but a published file that is not listed would silently be left
out of the MSI.
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$root = (Resolve-Path (Join-Path $PSScriptRoot "../..")).Path
$wxs = Join-Path $root "NewSetup/NewSetupFiles.wxs"
$publish = Join-Path $root "CDPIUI/bin/x64/Release/net8.0-windows10.0.22621.0/publish"

$listed = [regex]::Matches((Get-Content -Raw $wxs), 'Source="\$\(var\.SourceDir\)\\([^"]+)"') |
ForEach-Object { $_.Groups[1].Value.ToLowerInvariant() }
$published = Get-ChildItem -LiteralPath $publish -Recurse -File |
Where-Object { $_.Extension -ne ".pdb" } |
ForEach-Object { $_.FullName.Substring($publish.Length).TrimStart('\', '/').Replace('/', '\').ToLowerInvariant() }

$notListed = @($published | Where-Object { $listed -notcontains $_ })
$notPublished = @($listed | Where-Object { $published -notcontains $_ })

$notListed | ForEach-Object { Write-Output "Published but not in NewSetupFiles.wxs: $_" }
$notPublished | ForEach-Object { Write-Output "In NewSetupFiles.wxs but not published: $_" }
if ($notListed.Count + $notPublished.Count -gt 0) { throw "NewSetupFiles.wxs does not match the publish folder." }
Write-Output "NewSetupFiles.wxs matches the publish folder ($($listed.Count) files)."
Loading
Loading