feat(setup): add one-screen installer, uninstaller and silent mode
Titano.Setup reads the TPK1 payload from its own executable and installs per user (%LOCALAPPDATA%\Programs) or for all users (Program Files, relaunched elevated through ShellExecuteEx "runas"). Extraction is hash-verified into a staging folder and committed with rollback; upgrades replace files in place, remove obsolete ones and never touch %LOCALAPPDATA%\Titano. - Components, scope, folder (IFileOpenDialog picker), desktop and Start menu shortcuts (IShellLinkW), start-after-install, language picker - Add/Remove Programs entry, .titano file type, install log - /uninstall [/S] removes only logged files, shortcuts and registry entries; user data only when "Remove my data" is ticked; the uninstaller deletes itself through a temporary helper copy - Silent switches /S /DIR= /COMPONENTS= /ALLUSERS /NODESKTOP /NOSTARTMENU /LAUNCH /LANG= with documented exit codes; running programs are asked to close, never killed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
25 files changed
+2183
-11
No files matched your search
@@ -0,0 +1,60 @@
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Titano.Core.IO;
|
||||
|
||||
namespace Titano.Setup.Engine;
|
||||
|
||||
/// <summary>
|
||||
/// Record of one installation, kept as <c>install-log.json</c> in the install folder. The uninstaller carries no
|
||||
/// payload, so everything it removes comes from here: payload files, shortcuts and file types. User data is never
|
||||
/// listed.
|
||||
/// </summary>
|
||||
internal sealed class InstallLog
|
||||
{
|
||||
public const string FileName = "install-log.json";
|
||||
|
||||
public int FormatVersion { get; set; } = 1;
|
||||
public required string Product { get; set; }
|
||||
public required string Version { get; set; }
|
||||
public InstallScope Scope { get; set; }
|
||||
public List<string> Components { get; set; } = [];
|
||||
|
||||
/// <summary>Installed payload paths, relative to the install folder (the uninstaller and this log excluded).</summary>
|
||||
public List<string> Files { get; set; } = [];
|
||||
|
||||
/// <summary>Full paths of the shortcuts setup created.</summary>
|
||||
public List<string> Shortcuts { get; set; } = [];
|
||||
public List<InstalledAssociation> Associations { get; set; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public string ProductKey => SetupPaths.ProductKey(Product);
|
||||
|
||||
[JsonIgnore]
|
||||
public string UninstallerName => SetupPaths.UninstallerName(Product);
|
||||
|
||||
/// <summary>The log in <paramref name="directory"/>, or null when there is none or it is unreadable.</summary>
|
||||
public static InstallLog? TryLoad(string directory)
|
||||
{
|
||||
var path = Path.Combine(directory, FileName);
|
||||
try
|
||||
{
|
||||
return File.Exists(path) ? JsonSerializer.Deserialize(File.ReadAllBytes(path), InstallLogJson.Default.InstallLog) : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException or IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Titano.Core.Diagnostics.Log.Warning("setup", $"Install log '{path}' is unreadable", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(string directory) =>
|
||||
AtomicFile.WriteAllBytes(Path.Combine(directory, FileName), JsonSerializer.SerializeToUtf8Bytes(this, InstallLogJson.Default.InstallLog));
|
||||
}
|
||||
|
||||
/// <summary>A file type registered by setup.</summary>
|
||||
internal sealed record InstalledAssociation(string Extension, string ProgId);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, UseStringEnumConverter = true, RespectNullableAnnotations = true)]
|
||||
[JsonSerializable(typeof(InstallLog))]
|
||||
internal sealed partial class InstallLogJson : JsonSerializerContext;
|
||||
Reference in new issue
Block a user