Services, sign-in entries and shortcuts are matched against the full paths of the files the install log or the payload lists, never against everything under the install folder: an install into a shared folder such as D:\Apps or /DIR="C:\Program Files" no longer stops, starts or deletes other vendors' services or removes their Run values. The elevated step now takes the names the unelevated setup found (/SERVICES=... /NAMES=...) and reads each service again, acting only when it still starts a program of the folder's log or of its own payload (or, for Prune, a program of the folder that is gone). Programs are asked to close before any service is touched. On uninstall the services are deleted only once the programs have closed, just before the files go; a failed install or uninstall starts again the services it stopped, and after an upgrade setup starts exactly the services it stopped, whatever their start type. The Server component installs only for all users in a folder inside Program Files. In the window a custom folder outside it is invalid while the Server is selected, with a tooltip saying why; silent mode refuses it. An upgrade of an installation elsewhere cannot add the Server, and one it carried is dropped with its service. Sign-in entries use StartupCommand (the same file as on fix/shell-notify) and are removed by SetupRegistry.DeleteStartupEntries only when the client's or the Uploader's value starts a program the install log lists; an upgrade that drops a program removes its entry too. StartupEntries is gone. A shortcut that starts another product's existing copy is still left alone but now logged; uninstalling the product it starts hands it to another product of the same scope that lists it and has the same program, so the Uploader that stays keeps its shortcuts. Another registered Titano installation whose folder or log cannot be read now counts as using every program's data, so "Remove my data" never offers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
64 lines
2.7 KiB
C#
64 lines
2.7 KiB
C#
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, or would have created but found starting an existing program elsewhere
|
|
/// (another Titano product's copy, which hands them over to this one when it is uninstalled).
|
|
/// </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;
|