Programma di installazione per Windows scritto in casa, senza NSIS (C6, 2/4)
Decisione di Alberto del 18 novembre 2026: niente componenti esterni. Il programma di installazione è ora src/Febe.Installer, solo .NET: pubblicato per win-x64 autosufficiente, in un file solo, ridotto e compresso (circa 11 MB); lo stesso progetto, compilato per il sistema che costruisce, gli appende Febe.exe compresso con Brotli, la versione e un piè di pagina con SHA-256 (--impacchetta), lo ricontrolla (--verifica) e scrive lo zip portabile (--zip). Fa ciò che faceva lo script NSIS: installazione per utente in %LOCALAPPDATA%\Programs\Febe senza permessi di amministratore, collegamenti nel menu Start e (a scelta) sul desktop con ShellLink, voce in App installate sotto HKCU, controllo di WebView2, rifiuto con Febe aperto, aggiornamento che lascia i dati, «Disinstalla Febe.exe» che toglie solo il programma, i collegamenti, l'avvio con il computer e le librerie estratte, mai dati né libreria. Pagine con la finestra di dialogo di Windows; /S, /D= e /PROVA= per le prove. Tolti installer/febe.nsi, NSIS e zip dalla CI e dai documenti: costruisci.sh vuole solo il .NET SDK. Prove: pacchetto, riga di comando, installazione, aggiornamento e disinstallazione su un Windows finto (anche su Linux); su Windows il programma pubblicato davvero, installato e disinstallato senza domande in una cartella di prova, e la prima pagina aperta e annullata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c54d16946a
commit
7a54f1a460
37 files changed
+3275
-378
No files matched your search
@@ -0,0 +1,143 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>What the build asks of the tool (never on Windows of Alberto: in the CI and in installer/costruisci.sh).</summary>
|
||||
internal enum ToolCommand
|
||||
{
|
||||
None,
|
||||
|
||||
/// <summary><c>--impacchetta <installer> <Febe.exe> <version> <output></c></summary>
|
||||
Pack,
|
||||
|
||||
/// <summary><c>--verifica <package> <Febe.exe></c></summary>
|
||||
Verify,
|
||||
|
||||
/// <summary><c>--zip <output> <file>...</c></summary>
|
||||
Zip,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The command line of the installer and of the uninstaller, the same options as the installer before 18 November 2026:
|
||||
/// <list type="bullet">
|
||||
/// <item><c>/S</c>: silent, no dialog; the desktop shortcut is created, Febe is not started, an open Febe is an error.</item>
|
||||
/// <item><c>/D=<folder></c>: the program folder (only the installer); last, it takes the rest of the line even
|
||||
/// with spaces, as before.</item>
|
||||
/// <item><c>/PROVA=<folder></c>: for the tests, every folder and key under that one (<see cref="Locations.ForTest"/>).</item>
|
||||
/// </list>
|
||||
/// Internal to the uninstaller, which starts a copy of itself from %TEMP% so it can delete its own file:
|
||||
/// <c>/_?=<program folder></c> and <c>/ATTENDI=<process></c>.
|
||||
/// </summary>
|
||||
internal sealed record CommandLine
|
||||
{
|
||||
public bool Silent { get; init; }
|
||||
|
||||
public string? InstallFolder { get; init; }
|
||||
|
||||
public string? TestRoot { get; init; }
|
||||
|
||||
public string? UninstallFolder { get; init; }
|
||||
|
||||
public int? WaitFor { get; init; }
|
||||
|
||||
public ToolCommand Tool { get; init; }
|
||||
|
||||
public IReadOnlyList<string> ToolArguments { get; init; } = [];
|
||||
|
||||
/// <summary>The options again, for the copy of the uninstaller (all but the internal ones).</summary>
|
||||
public IReadOnlyList<string> PassOn()
|
||||
{
|
||||
var arguments = new List<string>();
|
||||
if (Silent)
|
||||
{
|
||||
arguments.Add("/S");
|
||||
}
|
||||
|
||||
if (TestRoot is not null)
|
||||
{
|
||||
arguments.Add("/PROVA=" + TestRoot);
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
/// <summary>Reads <paramref name="arguments"/>; an unknown option is an error with its text.</summary>
|
||||
/// <exception cref="ArgumentException">An option that does not exist or lacks its value.</exception>
|
||||
public static CommandLine Parse(IReadOnlyList<string> arguments)
|
||||
{
|
||||
if (arguments.Count > 0 && arguments[0].StartsWith("--", StringComparison.Ordinal))
|
||||
{
|
||||
var tool = arguments[0] switch
|
||||
{
|
||||
"--impacchetta" => ToolCommand.Pack,
|
||||
"--verifica" => ToolCommand.Verify,
|
||||
"--zip" => ToolCommand.Zip,
|
||||
_ => throw new ArgumentException($"Opzione sconosciuta: «{arguments[0]}»."),
|
||||
};
|
||||
var rest = arguments.Skip(1).ToArray();
|
||||
var valid = tool switch
|
||||
{
|
||||
ToolCommand.Pack => rest.Length == 4,
|
||||
ToolCommand.Verify => rest.Length == 2,
|
||||
_ => rest.Length >= 2,
|
||||
};
|
||||
if (!valid)
|
||||
{
|
||||
throw new ArgumentException(tool switch
|
||||
{
|
||||
ToolCommand.Pack => "Uso: --impacchetta <programma di installazione> <Febe.exe> <versione> <uscita>",
|
||||
ToolCommand.Verify => "Uso: --verifica <pacchetto> <Febe.exe>",
|
||||
_ => "Uso: --zip <uscita.zip> <file>...",
|
||||
});
|
||||
}
|
||||
|
||||
return new CommandLine { Tool = tool, ToolArguments = rest };
|
||||
}
|
||||
|
||||
var line = new CommandLine();
|
||||
for (var i = 0; i < arguments.Count; i++)
|
||||
{
|
||||
var argument = arguments[i];
|
||||
if (string.Equals(argument, "/S", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
line = line with { Silent = true };
|
||||
}
|
||||
else if (argument.StartsWith("/D=", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// The last option: the rest of the line is the folder even when unquoted.
|
||||
var folder = string.Join(' ', [argument[3..], .. arguments.Skip(i + 1)]);
|
||||
line = line with { InstallFolder = Folder(folder, "/D=") };
|
||||
break;
|
||||
}
|
||||
else if (argument.StartsWith("/PROVA=", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
line = line with { TestRoot = Folder(argument[7..], "/PROVA=") };
|
||||
}
|
||||
else if (argument.StartsWith("/_?=", StringComparison.Ordinal))
|
||||
{
|
||||
line = line with { UninstallFolder = Folder(argument[4..], "/_?=") };
|
||||
}
|
||||
else if (argument.StartsWith("/ATTENDI=", StringComparison.OrdinalIgnoreCase)
|
||||
&& int.TryParse(argument.AsSpan(9), System.Globalization.NumberStyles.None, System.Globalization.CultureInfo.InvariantCulture, out var process)
|
||||
&& process > 0)
|
||||
{
|
||||
line = line with { WaitFor = process };
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Opzione sconosciuta: «{argument}». Le opzioni sono /S e /D=<cartella>.");
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
private static string Folder(string value, string option)
|
||||
{
|
||||
var folder = value.Trim().Trim('"');
|
||||
if (folder.Length == 0 || !Path.IsPathFullyQualified(folder))
|
||||
{
|
||||
throw new ArgumentException($"{option} vuole un percorso completo, per esempio {option}D:\\Programmi\\Febe.");
|
||||
}
|
||||
|
||||
return Path.TrimEndingDirectorySeparator(folder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<!-- Il programma di installazione di Febe per Windows (specifica §12, domanda 6 di §16), scritto in casa al posto di
|
||||
quello fatto con uno strumento di terzi (decisione di Alberto del 18 novembre 2026). Nessun pacchetto: solo la
|
||||
libreria di base di .NET, il registro
|
||||
di Windows, l'interfaccia Shell per i collegamenti e la finestra di dialogo delle attività di Windows.
|
||||
|
||||
Un solo progetto per due usi:
|
||||
- pubblicato per win-x64 (installer/costruisci.sh) è il programma di installazione: un file solo, autosufficiente,
|
||||
ridotto (trimming) e compresso, a cui lo stesso progetto appende poi Febe.exe compresso e un piè di pagina;
|
||||
- compilato senza piattaforma è lo strumento che fa quell'unione e la controlla («impacchetta», «verifica»,
|
||||
«zip»): gira anche su Linux, nella CI.
|
||||
Le prove (tests/Febe.Tests e tests/Febe.Tests.Windows) leggono le sue parti interne. -->
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AssemblyName>Febe.Installer</AssemblyName>
|
||||
<RootNamespace>Febe.Installer</RootNamespace>
|
||||
<AssemblyTitle>Installazione di Febe</AssemblyTitle>
|
||||
<Description>Installazione di Febe</Description>
|
||||
<ApplicationIcon>..\Febe.Desktop\Febe.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
|
||||
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
|
||||
</PropertyGroup>
|
||||
<!-- Solo nella pubblicazione per una piattaforma: un file solo, con il suo runtime ridotto a ciò che usa. -->
|
||||
<PropertyGroup Condition="'$(RuntimeIdentifier)' != ''">
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
|
||||
<DebugType>none</DebugType>
|
||||
<DebuggerSupport>false</DebuggerSupport>
|
||||
<EventSourceSupport>false</EventSourceSupport>
|
||||
<MetricsSupport>false</MetricsSupport>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="Febe.Tests" />
|
||||
<InternalsVisibleTo Include="Febe.Tests.Windows" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>A shortcut (.lnk) to write.</summary>
|
||||
internal sealed record Shortcut(string Path, string Target, string WorkingDirectory, string Description, string IconPath, int IconIndex);
|
||||
|
||||
/// <summary>
|
||||
/// What the installation asks of Windows besides files: the registry of the current user (and only reading that of
|
||||
/// the machine), shortcuts, opening an address, starting a process. The real one is <c>WindowsSystem</c>; the tests use
|
||||
/// a fake, so the logic of <see cref="SetupActions"/> and <see cref="SetupFlow"/> runs on Linux too. Writing for every
|
||||
/// user is not even possible through this interface: nothing of the installation needs administrator rights.
|
||||
/// </summary>
|
||||
internal interface ISystemAccess
|
||||
{
|
||||
/// <summary>A string value under HKEY_CURRENT_USER; null when the key or the value is missing or not a string.</summary>
|
||||
string? ReadUserString(string key, string name);
|
||||
|
||||
/// <summary>A DWORD value under HKEY_CURRENT_USER; null when missing.</summary>
|
||||
int? ReadUserDword(string key, string name);
|
||||
|
||||
void WriteUserString(string key, string name, string value);
|
||||
|
||||
void WriteUserDword(string key, string name, int value);
|
||||
|
||||
/// <summary>The names of the values of a key of HKEY_CURRENT_USER, empty when the key is missing.</summary>
|
||||
IReadOnlyList<string> UserValueNames(string key);
|
||||
|
||||
void DeleteUserValue(string key, string name);
|
||||
|
||||
/// <summary>Deletes a key of HKEY_CURRENT_USER with everything under it; nothing when it is missing.</summary>
|
||||
void DeleteUserKeyTree(string key);
|
||||
|
||||
/// <summary>A string value under HKEY_LOCAL_MACHINE (64-bit view), only read.</summary>
|
||||
string? ReadMachineString(string key, string name);
|
||||
|
||||
void CreateShortcut(Shortcut shortcut);
|
||||
|
||||
/// <summary>Opens an address in the default browser.</summary>
|
||||
void OpenAddress(string address);
|
||||
|
||||
/// <summary>Starts a program and does not wait for it.</summary>
|
||||
void Start(string executable, IReadOnlyList<string> arguments, string workingDirectory);
|
||||
|
||||
/// <summary>Waits until the process <paramref name="processId"/> has ended, at most <paramref name="timeout"/>.</summary>
|
||||
void WaitForExit(int processId, TimeSpan timeout);
|
||||
|
||||
/// <summary>Waits a little before trying again (a file still held by a process that is ending).</summary>
|
||||
void Pause(TimeSpan delay);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>
|
||||
/// Where the installation writes: the folders of the user and the root of the registry keys of Febe. For the user
|
||||
/// these are the folders of Windows (<see cref="ForUser"/>); for the tests everything moves under one folder and one
|
||||
/// registry key of its own (<see cref="ForTest"/>, option <c>/PROVA=</c>), so a test never touches the real Start menu,
|
||||
/// the real desktop or the real entries of an installed Febe.
|
||||
/// </summary>
|
||||
internal sealed record Locations
|
||||
{
|
||||
/// <summary>%LOCALAPPDATA%: the default program folder is under it, and the default Data folder.</summary>
|
||||
public required string LocalAppData { get; init; }
|
||||
|
||||
/// <summary>The Programs folder of the user's Start menu.</summary>
|
||||
public required string StartMenuPrograms { get; init; }
|
||||
|
||||
public required string Desktop { get; init; }
|
||||
|
||||
public required string Pictures { get; init; }
|
||||
|
||||
public required string Temp { get; init; }
|
||||
|
||||
/// <summary>Empty for the user; for a test, the key under which every key of Febe is written.</summary>
|
||||
public string RegistryRoot { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>The folder given with <c>/PROVA=</c>, null for the user.</summary>
|
||||
public string? TestRoot { get; init; }
|
||||
|
||||
public string DefaultInstallFolder => Path.Combine(LocalAppData, "Programs", Product.Name);
|
||||
|
||||
public string StartMenuShortcut => Path.Combine(StartMenuPrograms, Product.ShortcutName);
|
||||
|
||||
public string DesktopShortcut => Path.Combine(Desktop, Product.ShortcutName);
|
||||
|
||||
public string DefaultDataFolder => Path.Combine(LocalAppData, Product.Name);
|
||||
|
||||
public string Library => Path.Combine(Pictures, Product.Name);
|
||||
|
||||
/// <summary>Where Febe.exe, a single file, extracts its native libraries on the first start (not data).</summary>
|
||||
public string ExtractionFolder => Path.Combine(Temp, ".net", Product.Name);
|
||||
|
||||
public string UninstallKey => RegistryRoot + Product.UninstallKey;
|
||||
|
||||
public string FebeKey => RegistryRoot + Product.FebeKey;
|
||||
|
||||
public string RunKey => RegistryRoot + Product.RunKey;
|
||||
|
||||
/// <summary>The folders of Windows for the current user.</summary>
|
||||
public static Locations ForUser() => new()
|
||||
{
|
||||
LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
StartMenuPrograms = Environment.GetFolderPath(Environment.SpecialFolder.Programs),
|
||||
Desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
Pictures = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
|
||||
Temp = Path.TrimEndingDirectorySeparator(Path.GetTempPath()),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Everything under <paramref name="root"/>: AppData, Menu, Desktop, Immagini and Temp inside it, and the keys under
|
||||
/// <c>HKCU\Software\FebeProve\<name of the folder></c>.
|
||||
/// </summary>
|
||||
public static Locations ForTest(string root)
|
||||
{
|
||||
var full = Path.TrimEndingDirectorySeparator(Path.GetFullPath(root));
|
||||
var name = Path.GetFileName(full);
|
||||
if (name.Length == 0 || name.Contains('\\', StringComparison.Ordinal))
|
||||
{
|
||||
throw new ArgumentException("Cartella di prova non valida.", nameof(root));
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
LocalAppData = Path.Combine(full, "AppData"),
|
||||
StartMenuPrograms = Path.Combine(full, "Menu"),
|
||||
Desktop = Path.Combine(full, "Desktop"),
|
||||
Pictures = Path.Combine(full, "Immagini"),
|
||||
Temp = Path.Combine(full, "Temp"),
|
||||
RegistryRoot = TestRegistryRoot(full),
|
||||
TestRoot = full,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The registry key under which a test installation in <paramref name="root"/> writes.</summary>
|
||||
public static string TestRegistryRoot(string root) =>
|
||||
@"Software\FebeProve\" + Path.GetFileName(Path.TrimEndingDirectorySeparator(Path.GetFullPath(root))) + @"\";
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>What a package is: the installer with Febe.exe inside, or the uninstaller left in the program folder.</summary>
|
||||
internal enum PackageKind
|
||||
{
|
||||
Installer = 1,
|
||||
Uninstaller = 2,
|
||||
}
|
||||
|
||||
/// <summary>The footer of a package, read back.</summary>
|
||||
internal sealed record PackageInfo(
|
||||
PackageKind Kind,
|
||||
long ProgramStart,
|
||||
long DataLength,
|
||||
long ProgramLength,
|
||||
byte[] ProgramHash,
|
||||
string Version)
|
||||
{
|
||||
/// <summary>The length of the program itself (the published installer), before the data: where the data start.</summary>
|
||||
public long StubLength => ProgramStart;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The package: the published installer (a .NET single file) followed by Febe.exe compressed with Brotli, the version
|
||||
/// and a fixed footer of <see cref="FooterLength"/> bytes at the very end. The host of a single file finds its bundle
|
||||
/// through an offset written inside the executable, not from the end of the file, so what follows does not disturb it.
|
||||
/// The uninstaller is the same program with a footer of its own and no data.
|
||||
/// <code>
|
||||
/// [installer][Febe.exe, Brotli][version, UTF-8][footer]
|
||||
/// footer, little-endian: «FEBE-PKG» · format 1 (int32) · kind (int32) · length of the installer (int64)
|
||||
/// · length of the data (int64) · length of Febe.exe (int64) · length of the version (int32)
|
||||
/// · SHA-256 of Febe.exe (32 bytes) · 0 (int32)
|
||||
/// </code>
|
||||
/// </summary>
|
||||
internal static partial class Package
|
||||
{
|
||||
public const int FooterLength = 80;
|
||||
|
||||
private const int FormatVersion = 1;
|
||||
|
||||
private const int MaxVersionLength = 64;
|
||||
|
||||
/// <summary>Brotli: quality 5 and a 16 MB window, a few seconds for Febe.exe and within 1% of the best.</summary>
|
||||
private const int Quality = 5;
|
||||
|
||||
private const int Window = 24;
|
||||
|
||||
private const int BufferSize = 1 << 20;
|
||||
|
||||
private static ReadOnlySpan<byte> Magic => "FEBE-PKG"u8;
|
||||
|
||||
/// <summary>The footer of <paramref name="path"/>; null when the file is not a package (no footer at the end).</summary>
|
||||
/// <exception cref="InvalidDataException">The footer is there but does not describe the file.</exception>
|
||||
public static PackageInfo? Read(string path)
|
||||
{
|
||||
using var file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete);
|
||||
return Read(file);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Read(string)"/>
|
||||
public static PackageInfo? Read(FileStream file)
|
||||
{
|
||||
var length = file.Length;
|
||||
if (length < FooterLength)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Span<byte> footer = stackalloc byte[FooterLength];
|
||||
file.Position = length - FooterLength;
|
||||
file.ReadExactly(footer);
|
||||
if (!footer[..8].SequenceEqual(Magic))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var format = BinaryPrimitives.ReadInt32LittleEndian(footer[8..]);
|
||||
var kind = (PackageKind)BinaryPrimitives.ReadInt32LittleEndian(footer[12..]);
|
||||
var programStart = BinaryPrimitives.ReadInt64LittleEndian(footer[16..]);
|
||||
var dataLength = BinaryPrimitives.ReadInt64LittleEndian(footer[24..]);
|
||||
var programLength = BinaryPrimitives.ReadInt64LittleEndian(footer[32..]);
|
||||
var versionLength = BinaryPrimitives.ReadInt32LittleEndian(footer[40..]);
|
||||
var hash = footer.Slice(44, 32).ToArray();
|
||||
if (format != FormatVersion
|
||||
|| kind is not (PackageKind.Installer or PackageKind.Uninstaller)
|
||||
|| programStart <= 0 || dataLength < 0 || programLength < 0
|
||||
|| versionLength <= 0 || versionLength > MaxVersionLength
|
||||
|| programStart + dataLength + versionLength + FooterLength != length
|
||||
|| (kind == PackageKind.Uninstaller && (dataLength != 0 || programLength != 0))
|
||||
|| (kind == PackageKind.Installer && (dataLength == 0 || programLength == 0)))
|
||||
{
|
||||
throw new InvalidDataException(Texts.Damaged);
|
||||
}
|
||||
|
||||
Span<byte> versionBytes = stackalloc byte[versionLength];
|
||||
file.Position = programStart + dataLength;
|
||||
file.ReadExactly(versionBytes);
|
||||
var version = Encoding.UTF8.GetString(versionBytes);
|
||||
if (!IsVersion(version))
|
||||
{
|
||||
throw new InvalidDataException(Texts.Damaged);
|
||||
}
|
||||
|
||||
return new PackageInfo(kind, programStart, dataLength, programLength, hash, version);
|
||||
}
|
||||
|
||||
/// <summary>A version as the build writes it: x.y.z, optionally followed by -something or +something.</summary>
|
||||
public static bool IsVersion(string? version) =>
|
||||
version is { Length: > 0 and <= MaxVersionLength } && VersionPattern().IsMatch(version);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the package <paramref name="output"/>: the published installer <paramref name="installer"/>, then
|
||||
/// <paramref name="program"/> (Febe.exe) compressed, the version and the footer. Written beside and renamed at the
|
||||
/// end, so a failure never leaves half a package.
|
||||
/// </summary>
|
||||
public static PackageInfo Write(string installer, string program, string version, string output)
|
||||
{
|
||||
if (!IsVersion(version))
|
||||
{
|
||||
throw new ArgumentException($"Versione non valida: «{version}» (serve x.y.z).", nameof(version));
|
||||
}
|
||||
|
||||
if (Read(installer) is not null)
|
||||
{
|
||||
throw new ArgumentException("Il programma di installazione contiene già un pacchetto: serve quello appena pubblicato.", nameof(installer));
|
||||
}
|
||||
|
||||
var partial = output + ".part";
|
||||
try
|
||||
{
|
||||
PackageInfo info;
|
||||
using (var target = new FileStream(partial, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
using (var source = File.OpenRead(installer))
|
||||
{
|
||||
source.CopyTo(target, BufferSize);
|
||||
}
|
||||
|
||||
var programStart = target.Position;
|
||||
if (programStart == 0)
|
||||
{
|
||||
throw new ArgumentException("Il programma di installazione è vuoto.", nameof(installer));
|
||||
}
|
||||
|
||||
byte[] hash;
|
||||
long programLength;
|
||||
using (var source = File.OpenRead(program))
|
||||
{
|
||||
(programLength, hash) = Compress(source, target);
|
||||
}
|
||||
|
||||
if (programLength == 0)
|
||||
{
|
||||
throw new ArgumentException("Il programma da installare è vuoto.", nameof(program));
|
||||
}
|
||||
|
||||
var dataLength = target.Position - programStart;
|
||||
info = new PackageInfo(PackageKind.Installer, programStart, dataLength, programLength, hash, version);
|
||||
WriteTail(target, info);
|
||||
target.Flush(flushToDisk: true);
|
||||
}
|
||||
|
||||
File.Move(partial, output, overwrite: true);
|
||||
return info;
|
||||
}
|
||||
catch
|
||||
{
|
||||
TryDelete(partial);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decompresses Febe.exe from the package <paramref name="package"/> into <paramref name="destination"/>, checking
|
||||
/// its length and SHA-256; <paramref name="progress"/> gets the share written, from 0 to 1.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidDataException">The data are not the program the footer describes.</exception>
|
||||
public static void ExtractProgram(string package, PackageInfo info, string destination, Action<double>? progress = null)
|
||||
{
|
||||
if (info.Kind != PackageKind.Installer)
|
||||
{
|
||||
throw new InvalidOperationException("Il pacchetto non contiene Febe.");
|
||||
}
|
||||
|
||||
var buffer = ArrayPool<byte>.Shared.Rent(BufferSize);
|
||||
try
|
||||
{
|
||||
using var file = new FileStream(package, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete, 1, FileOptions.SequentialScan);
|
||||
using var slice = new SliceStream(file, info.ProgramStart, info.DataLength);
|
||||
using var brotli = new BrotliStream(slice, CompressionMode.Decompress);
|
||||
using var hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256);
|
||||
using var target = new FileStream(destination, FileMode.Create, FileAccess.Write, FileShare.None, 1, FileOptions.SequentialScan);
|
||||
target.SetLength(info.ProgramLength);
|
||||
long written = 0;
|
||||
while (true)
|
||||
{
|
||||
int read;
|
||||
try
|
||||
{
|
||||
read = brotli.Read(buffer, 0, BufferSize);
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidDataException or InvalidOperationException or EndOfStreamException)
|
||||
{
|
||||
// Brotli refuses the data, or they end before the footer says.
|
||||
throw new InvalidDataException(Texts.Damaged, ex);
|
||||
}
|
||||
|
||||
if (read == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
written += read;
|
||||
if (written > info.ProgramLength)
|
||||
{
|
||||
throw new InvalidDataException(Texts.Damaged);
|
||||
}
|
||||
|
||||
hash.AppendData(buffer, 0, read);
|
||||
target.Write(buffer, 0, read);
|
||||
progress?.Invoke((double)written / info.ProgramLength);
|
||||
}
|
||||
|
||||
Span<byte> actual = stackalloc byte[32];
|
||||
hash.GetHashAndReset(actual);
|
||||
if (written != info.ProgramLength || !actual.SequenceEqual(info.ProgramHash))
|
||||
{
|
||||
throw new InvalidDataException(Texts.Damaged);
|
||||
}
|
||||
|
||||
target.Flush(flushToDisk: true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the uninstaller into <paramref name="destination"/>: the program of <paramref name="package"/> without
|
||||
/// Febe.exe, with a footer of kind <see cref="PackageKind.Uninstaller"/> and the same version.
|
||||
/// </summary>
|
||||
public static void WriteUninstaller(string package, PackageInfo info, string destination)
|
||||
{
|
||||
using var source = new FileStream(package, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete);
|
||||
using var target = new FileStream(destination, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
using (var program = new SliceStream(source, 0, info.StubLength))
|
||||
{
|
||||
program.CopyTo(target, BufferSize);
|
||||
}
|
||||
|
||||
WriteTail(target, new PackageInfo(PackageKind.Uninstaller, info.StubLength, 0, 0, new byte[32], info.Version));
|
||||
target.Flush(flushToDisk: true);
|
||||
}
|
||||
|
||||
private static (long Length, byte[] Hash) Compress(Stream source, Stream target)
|
||||
{
|
||||
var input = ArrayPool<byte>.Shared.Rent(BufferSize);
|
||||
var output = ArrayPool<byte>.Shared.Rent(BufferSize);
|
||||
try
|
||||
{
|
||||
using var encoder = new BrotliEncoder(Quality, Window);
|
||||
using var hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256);
|
||||
long length = 0;
|
||||
while (true)
|
||||
{
|
||||
var read = source.Read(input, 0, BufferSize);
|
||||
var final = read == 0;
|
||||
length += read;
|
||||
hash.AppendData(input, 0, read);
|
||||
var pending = input.AsSpan(0, read);
|
||||
while (true)
|
||||
{
|
||||
var status = encoder.Compress(pending, output, out var consumed, out var produced, final);
|
||||
target.Write(output, 0, produced);
|
||||
pending = pending[consumed..];
|
||||
if (status is OperationStatus.Done or OperationStatus.NeedMoreData)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == OperationStatus.InvalidData)
|
||||
{
|
||||
throw new InvalidDataException("Compressione non riuscita.");
|
||||
}
|
||||
}
|
||||
|
||||
if (final)
|
||||
{
|
||||
return (length, hash.GetHashAndReset());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(input);
|
||||
ArrayPool<byte>.Shared.Return(output);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteTail(Stream target, PackageInfo info)
|
||||
{
|
||||
var version = Encoding.UTF8.GetBytes(info.Version);
|
||||
target.Write(version);
|
||||
Span<byte> footer = stackalloc byte[FooterLength];
|
||||
footer.Clear();
|
||||
Magic.CopyTo(footer);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(footer[8..], FormatVersion);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(footer[12..], (int)info.Kind);
|
||||
BinaryPrimitives.WriteInt64LittleEndian(footer[16..], info.ProgramStart);
|
||||
BinaryPrimitives.WriteInt64LittleEndian(footer[24..], info.DataLength);
|
||||
BinaryPrimitives.WriteInt64LittleEndian(footer[32..], info.ProgramLength);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(footer[40..], version.Length);
|
||||
info.ProgramHash.CopyTo(footer[44..]);
|
||||
target.Write(footer);
|
||||
}
|
||||
|
||||
internal static void TryDelete(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// Our own temporary file: left behind, it is overwritten next time.
|
||||
}
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$", RegexOptions.CultureInvariant)]
|
||||
private static partial Regex VersionPattern();
|
||||
}
|
||||
|
||||
/// <summary>A read-only window on a part of a stream, which it never closes.</summary>
|
||||
internal sealed class SliceStream : Stream
|
||||
{
|
||||
private readonly Stream _inner;
|
||||
private readonly long _start;
|
||||
private readonly long _length;
|
||||
private long _position;
|
||||
|
||||
public SliceStream(Stream inner, long start, long length)
|
||||
{
|
||||
_inner = inner;
|
||||
_start = start;
|
||||
_length = length;
|
||||
}
|
||||
|
||||
public override bool CanRead => true;
|
||||
|
||||
public override bool CanSeek => false;
|
||||
|
||||
public override bool CanWrite => false;
|
||||
|
||||
public override long Length => _length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get => _position;
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count) => Read(buffer.AsSpan(offset, count));
|
||||
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
var left = _length - _position;
|
||||
if (left <= 0 || buffer.IsEmpty)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (buffer.Length > left)
|
||||
{
|
||||
buffer = buffer[..(int)left];
|
||||
}
|
||||
|
||||
_inner.Position = _start + _position;
|
||||
var read = _inner.Read(buffer);
|
||||
if (read == 0)
|
||||
{
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
_position += read;
|
||||
return read;
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
|
||||
|
||||
public override void SetLength(long value) => throw new NotSupportedException();
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>
|
||||
/// The fixed facts of the installation (spec §12, question 6 of §16): names, registry keys and addresses. The keys
|
||||
/// <see cref="FebeKey"/>, <see cref="RunKey"/> and the values under them are those Febe for Windows writes itself
|
||||
/// (<c>RegistryLocationStore</c> and <c>Autostart</c> in the desktop projects); a test checks they agree.
|
||||
/// </summary>
|
||||
internal static class Product
|
||||
{
|
||||
public const string Name = "Febe";
|
||||
|
||||
public const string Publisher = "Alberto Balbo";
|
||||
|
||||
public const string Executable = "Febe.exe";
|
||||
|
||||
public const string Uninstaller = "Disinstalla Febe.exe";
|
||||
|
||||
public const string ShortcutName = "Febe.lnk";
|
||||
|
||||
public const string ShortcutDescription = "Archivio personale di foto, video e storie da Instagram";
|
||||
|
||||
/// <summary>Apps installed (Programs and Features), per user, under HKEY_CURRENT_USER.</summary>
|
||||
public const string UninstallKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\Febe";
|
||||
|
||||
/// <summary>Febe's own key: «CartellaDati» says where the data are after a move (spec §12).</summary>
|
||||
public const string FebeKey = @"Software\Febe";
|
||||
|
||||
public const string DataFolderValue = "CartellaDati";
|
||||
|
||||
/// <summary>«Start Febe with the computer»: the value «Febe» and, for a Febe started with --dati, «Febe-…».</summary>
|
||||
public const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
|
||||
public const string AutostartValue = "Febe";
|
||||
|
||||
public const string AutostartPrefix = "Febe-";
|
||||
|
||||
/// <summary>The Evergreen runtime of WebView2: «pv» under this client of EdgeUpdate is its version.</summary>
|
||||
public const string EdgeUpdateClient = @"Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}";
|
||||
|
||||
public const string WebView2Page = "https://developer.microsoft.com/microsoft-edge/webview2/";
|
||||
|
||||
public const string Site = "https://gitea.encke-hake.ts.net/Alby96/Febe";
|
||||
|
||||
/// <summary>The prefix of the copies of the uninstaller that run from the temporary folder.</summary>
|
||||
public const string UninstallerCopyPrefix = "Febe-disinstalla-";
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using Febe.Installer.Windows;
|
||||
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>
|
||||
/// The entry point. With a package footer at the end of its own file it is the installer (Febe.exe inside) or the
|
||||
/// uninstaller; with <c>--impacchetta</c>, <c>--verifica</c> or <c>--zip</c> it is the build tool, on any system.
|
||||
/// </summary>
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
CommandLine line;
|
||||
try
|
||||
{
|
||||
line = CommandLine.Parse(args);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return Report(ex.Message, args);
|
||||
}
|
||||
|
||||
if (line.Tool != ToolCommand.None)
|
||||
{
|
||||
return RunTool(line);
|
||||
}
|
||||
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
Console.Error.WriteLine(Texts.WindowsOnly);
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
return RunOnWindows(line);
|
||||
}
|
||||
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
private static int RunOnWindows(CommandLine line)
|
||||
{
|
||||
var self = Environment.ProcessPath;
|
||||
var locations = line.TestRoot is { } root ? Locations.ForTest(root) : Locations.ForUser();
|
||||
// With /S the reason of a failure goes to the standard error, in UTF-8 whatever the code page of the console.
|
||||
ISetupInterface ui = line.Silent
|
||||
? new SilentInterface(new StreamWriter(Console.OpenStandardError(), new System.Text.UTF8Encoding(false)) { AutoFlush = true })
|
||||
: new DialogInterface(locations);
|
||||
PackageInfo? package;
|
||||
try
|
||||
{
|
||||
package = self is null ? null : Package.Read(self);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException)
|
||||
{
|
||||
ui.Failed(uninstalling: false, Texts.Failure(ex));
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
if (package is null || self is null)
|
||||
{
|
||||
ui.Failed(uninstalling: false, Texts.NoPackage);
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
SetupFlow.RemoveOldUninstallerCopies(locations, self);
|
||||
var flow = new SetupFlow(new WindowsSystem(), locations, ui);
|
||||
try
|
||||
{
|
||||
return package.Kind == PackageKind.Installer ? flow.Install(self, package, line) : flow.Uninstall(self, line);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or System.ComponentModel.Win32Exception or System.Runtime.InteropServices.COMException)
|
||||
{
|
||||
ui.Failed(package.Kind == PackageKind.Uninstaller, Texts.Failure(ex));
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A wrong command line: said in a dialog, or on the standard error with /S or for the build tool.</summary>
|
||||
private static int Report(string message, string[] args)
|
||||
{
|
||||
var silent = args.Any(a => string.Equals(a, "/S", StringComparison.OrdinalIgnoreCase));
|
||||
if (OperatingSystem.IsWindows() && !silent && !(args.Length > 0 && args[0].StartsWith("--", StringComparison.Ordinal)))
|
||||
{
|
||||
new DialogInterface(Locations.ForUser()).Failed(uninstalling: false, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine(message);
|
||||
}
|
||||
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
private static int RunTool(CommandLine line)
|
||||
{
|
||||
var a = line.ToolArguments;
|
||||
try
|
||||
{
|
||||
switch (line.Tool)
|
||||
{
|
||||
case ToolCommand.Pack:
|
||||
{
|
||||
var info = Package.Write(a[0], a[1], a[2], a[3]);
|
||||
Console.WriteLine($"Pacchetto {Path.GetFileName(a[3])}: programma {info.StubLength / 1048576.0:F1} MB, Febe.exe {info.ProgramLength / 1048576.0:F1} MB compresso in {info.DataLength / 1048576.0:F1} MB, versione {info.Version}.");
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
|
||||
case ToolCommand.Verify:
|
||||
return Verify(a[0], a[1]);
|
||||
|
||||
default:
|
||||
Zip(a[0], a.Skip(1).ToArray());
|
||||
Console.WriteLine($"Zip {Path.GetFileName(a[0])}: {a.Count - 1} file.");
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArgumentException)
|
||||
{
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks a package as the installer will read it: a footer of an installer, and inside exactly
|
||||
/// <paramref name="program"/>, decompressed to a file beside and compared byte for byte (then deleted).
|
||||
/// </summary>
|
||||
private static int Verify(string packagePath, string program)
|
||||
{
|
||||
var info = Package.Read(packagePath);
|
||||
if (info is not { Kind: PackageKind.Installer })
|
||||
{
|
||||
Console.Error.WriteLine($"{packagePath} non è un programma di installazione di Febe.");
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
var extracted = packagePath + ".verifica";
|
||||
try
|
||||
{
|
||||
Package.ExtractProgram(packagePath, info, extracted);
|
||||
if (!SameContent(extracted, program))
|
||||
{
|
||||
Console.Error.WriteLine($"Il Febe.exe dentro {Path.GetFileName(packagePath)} non è {program}.");
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Package.TryDelete(extracted);
|
||||
}
|
||||
|
||||
Console.WriteLine($"{Path.GetFileName(packagePath)}: Febe {info.Version}, Febe.exe integro ({info.ProgramLength} byte).");
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
|
||||
private static bool SameContent(string a, string b)
|
||||
{
|
||||
using var first = File.OpenRead(a);
|
||||
using var second = File.OpenRead(b);
|
||||
return first.Length == second.Length && SHA256.HashData(first).AsSpan().SequenceEqual(SHA256.HashData(second));
|
||||
}
|
||||
|
||||
/// <summary>The portable zip: each file at the top, by its name, at the strongest compression of Deflate.</summary>
|
||||
internal static void Zip(string output, IReadOnlyList<string> files)
|
||||
{
|
||||
var partial = output + ".part";
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(partial, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
using (var archive = new ZipArchive(stream, ZipArchiveMode.Create))
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
archive.CreateEntryFromFile(file, Path.GetFileName(file), CompressionLevel.SmallestSize);
|
||||
}
|
||||
}
|
||||
|
||||
File.Move(partial, output, overwrite: true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Package.TryDelete(partial);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>What an installation asks for: from which package, into which folder, with or without the desktop shortcut.</summary>
|
||||
internal sealed record InstallRequest(string PackagePath, PackageInfo Package, string InstallFolder, bool DesktopShortcut);
|
||||
|
||||
/// <summary>
|
||||
/// The work of the installer and of the uninstaller, without dialogs (spec §12, question 6 of §16): exactly what the
|
||||
/// installer built with a third-party tool did until 18 November 2026.
|
||||
/// <list type="bullet">
|
||||
/// <item>Per user, without administrator rights, by default in <c>%LOCALAPPDATA%\Programs\Febe</c>.</item>
|
||||
/// <item>Febe.exe and «Disinstalla Febe.exe»; the shortcut in the Start menu, the one on the desktop if chosen.</item>
|
||||
/// <item>The uninstall entry under HKCU (Apps installed).</item>
|
||||
/// <item>An installation over an existing one replaces the program and keeps everything else.</item>
|
||||
/// <item>The uninstallation removes only the program, its shortcuts, its registry entries and the libraries Febe.exe
|
||||
/// extracts by itself: NEVER the Data folder or the library, and it asks nothing about them.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
internal sealed class SetupActions(ISystemAccess system, Locations locations)
|
||||
{
|
||||
private const string NewSuffix = ".nuovo";
|
||||
|
||||
public Locations Locations => locations;
|
||||
|
||||
/// <summary>
|
||||
/// True when Febe.exe in <paramref name="installFolder"/> is running: a running program cannot be opened for
|
||||
/// writing, so it could be neither replaced nor deleted.
|
||||
/// </summary>
|
||||
public static bool IsFebeOpen(string installFolder)
|
||||
{
|
||||
var executable = Path.Combine(installFolder, Product.Executable);
|
||||
if (!File.Exists(executable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var stream = new FileStream(executable, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete);
|
||||
return false;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The version recorded by an earlier installation, null for none.</summary>
|
||||
public string? InstalledVersion() => system.ReadUserString(locations.UninstallKey, "DisplayVersion");
|
||||
|
||||
/// <summary>
|
||||
/// The version of the WebView2 runtime of Microsoft, null when it is missing. The Evergreen runtime is installed for
|
||||
/// the whole computer (32-bit node of the registry on 64-bit Windows) or for the user only; «0.0.0.0» means removed.
|
||||
/// </summary>
|
||||
public string? WebView2Version()
|
||||
{
|
||||
foreach (var value in new[]
|
||||
{
|
||||
system.ReadMachineString(@"SOFTWARE\WOW6432Node\" + Product.EdgeUpdateClient, "pv"),
|
||||
system.ReadMachineString(@"SOFTWARE\" + Product.EdgeUpdateClient, "pv"),
|
||||
system.ReadUserString(@"Software\" + Product.EdgeUpdateClient, "pv"),
|
||||
})
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value) && value != "0.0.0.0")
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Where the data are: the folder chosen in Impostazioni (recorded by Febe) or the default one.</summary>
|
||||
public string DataFolder() =>
|
||||
system.ReadUserString(locations.FebeKey, Product.DataFolderValue) is { Length: > 0 } folder ? folder : locations.DefaultDataFolder;
|
||||
|
||||
/// <summary>The command line of the uninstaller, as the uninstall entry records it.</summary>
|
||||
public string UninstallCommand(string installFolder, bool silent)
|
||||
{
|
||||
var command = $"\"{Path.Combine(installFolder, Product.Uninstaller)}\"";
|
||||
if (silent)
|
||||
{
|
||||
command += " /S";
|
||||
}
|
||||
|
||||
if (locations.TestRoot is { } root)
|
||||
{
|
||||
command += $" \"/PROVA={root}\"";
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs: Febe.exe (written beside and renamed, so an interrupted copy never leaves half a program), the
|
||||
/// uninstaller, the shortcuts and the uninstall entry. <paramref name="progress"/> gets the share done, 0 to 1.
|
||||
/// </summary>
|
||||
public void Install(InstallRequest request, Action<double>? progress = null)
|
||||
{
|
||||
var folder = request.InstallFolder;
|
||||
Directory.CreateDirectory(folder);
|
||||
var executable = Path.Combine(folder, Product.Executable);
|
||||
Replace(executable, partial => Package.ExtractProgram(request.PackagePath, request.Package, partial, share => progress?.Invoke(share * 0.95)));
|
||||
Replace(Path.Combine(folder, Product.Uninstaller), partial => Package.WriteUninstaller(request.PackagePath, request.Package, partial));
|
||||
progress?.Invoke(0.97);
|
||||
|
||||
system.CreateShortcut(ShortcutTo(locations.StartMenuShortcut, folder));
|
||||
|
||||
var key = locations.UninstallKey;
|
||||
system.WriteUserString(key, "DisplayName", Product.Name);
|
||||
system.WriteUserString(key, "DisplayVersion", request.Package.Version);
|
||||
system.WriteUserString(key, "Publisher", Product.Publisher);
|
||||
system.WriteUserString(key, "DisplayIcon", executable + ",0");
|
||||
system.WriteUserString(key, "InstallLocation", folder);
|
||||
system.WriteUserString(key, "UninstallString", UninstallCommand(folder, silent: false));
|
||||
system.WriteUserString(key, "QuietUninstallString", UninstallCommand(folder, silent: true));
|
||||
system.WriteUserString(key, "URLInfoAbout", Product.Site);
|
||||
system.WriteUserDword(key, "NoModify", 1);
|
||||
system.WriteUserDword(key, "NoRepair", 1);
|
||||
system.WriteUserDword(key, "EstimatedSize", EstimatedSizeInKb(folder));
|
||||
|
||||
if (request.DesktopShortcut)
|
||||
{
|
||||
system.CreateShortcut(ShortcutTo(locations.DesktopShortcut, folder));
|
||||
}
|
||||
|
||||
progress?.Invoke(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls the Febe of <paramref name="installFolder"/>: the program files (the folder itself only if nothing
|
||||
/// else is left in it), the two shortcuts, «Start with the computer» («Febe» and the «Febe-…» values that start
|
||||
/// this Febe.exe), the uninstall entry and the libraries extracted under %TEMP%. Nothing else.
|
||||
/// </summary>
|
||||
public void Uninstall(string installFolder)
|
||||
{
|
||||
var executable = Path.Combine(installFolder, Product.Executable);
|
||||
DeleteFile(executable);
|
||||
DeleteFile(executable + NewSuffix);
|
||||
DeleteUninstaller(Path.Combine(installFolder, Product.Uninstaller));
|
||||
DeleteFile(Path.Combine(installFolder, Product.Uninstaller) + NewSuffix);
|
||||
try
|
||||
{
|
||||
// Only when empty: whatever else is there is not ours to delete.
|
||||
Directory.Delete(installFolder, recursive: false);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
}
|
||||
|
||||
DeleteFile(locations.StartMenuShortcut);
|
||||
DeleteFile(locations.DesktopShortcut);
|
||||
|
||||
// «Start Febe with the computer» would point to a program that is no longer there.
|
||||
system.DeleteUserValue(locations.RunKey, Product.AutostartValue);
|
||||
var command = $"\"{executable}\"";
|
||||
foreach (var name in system.UserValueNames(locations.RunKey))
|
||||
{
|
||||
if (name.StartsWith(Product.AutostartPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
&& system.ReadUserString(locations.RunKey, name) is { } value
|
||||
&& value.StartsWith(command, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
system.DeleteUserValue(locations.RunKey, name);
|
||||
}
|
||||
}
|
||||
|
||||
system.DeleteUserKeyTree(locations.UninstallKey);
|
||||
|
||||
// The native libraries Febe.exe extracts by itself on the first start: not data.
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(locations.ExtractionFolder))
|
||||
{
|
||||
Directory.Delete(locations.ExtractionFolder, recursive: true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// A portable Febe still running holds them: they stay, Windows cleans %TEMP%.
|
||||
}
|
||||
}
|
||||
|
||||
private static Shortcut ShortcutTo(string path, string installFolder)
|
||||
{
|
||||
var executable = Path.Combine(installFolder, Product.Executable);
|
||||
return new Shortcut(path, executable, installFolder, Product.ShortcutDescription, executable, 0);
|
||||
}
|
||||
|
||||
private static void Replace(string path, Action<string> write)
|
||||
{
|
||||
var partial = path + NewSuffix;
|
||||
try
|
||||
{
|
||||
write(partial);
|
||||
File.Move(partial, path, overwrite: true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Package.TryDelete(partial);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeleteFile(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The uninstaller that started this one may take a moment to end and release its file.</summary>
|
||||
private void DeleteUninstaller(string path)
|
||||
{
|
||||
for (var attempt = 0; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteFile(path);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when ((ex is IOException or UnauthorizedAccessException) && attempt < 20)
|
||||
{
|
||||
system.Pause(TimeSpan.FromMilliseconds(250));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int EstimatedSizeInKb(string folder)
|
||||
{
|
||||
long bytes = 0;
|
||||
foreach (var file in new DirectoryInfo(folder).EnumerateFiles("*", SearchOption.AllDirectories))
|
||||
{
|
||||
bytes += file.Length;
|
||||
}
|
||||
|
||||
return (int)Math.Min(int.MaxValue, bytes / 1024);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>The exit codes of the installer and of the uninstaller.</summary>
|
||||
internal static class ExitCodes
|
||||
{
|
||||
public const int Done = 0;
|
||||
|
||||
/// <summary>Alberto said no: «Annulla».</summary>
|
||||
public const int Cancelled = 1;
|
||||
|
||||
/// <summary>Something went wrong, or Febe is open in silent mode: nothing was changed, or only the part said.</summary>
|
||||
public const int Failed = 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The dialogs of the installation: the windows of Windows (<c>DialogInterface</c>) or, with <c>/S</c>, none
|
||||
/// (<see cref="SilentInterface"/>). The tests use a fake that answers as told.
|
||||
/// </summary>
|
||||
internal interface ISetupInterface
|
||||
{
|
||||
/// <summary>The first page; null for «Annulla», otherwise whether the desktop shortcut is wanted.</summary>
|
||||
bool? Welcome(string version, string? installedVersion, string installFolder);
|
||||
|
||||
/// <summary>Febe is open: true to try again (after closing it), false to give up.</summary>
|
||||
bool RetryWhenFebeIsOpen(bool uninstalling);
|
||||
|
||||
/// <summary>Runs <paramref name="work"/> showing its progress (0 to 1); its exception comes out of here.</summary>
|
||||
void RunWithProgress(string version, string installFolder, Action<Action<double>> work);
|
||||
|
||||
/// <summary>WebView2 is missing: true to open the page of Microsoft.</summary>
|
||||
bool OfferWebView2Page();
|
||||
|
||||
/// <summary>The last page of the installation: true to start Febe now.</summary>
|
||||
bool Installed();
|
||||
|
||||
bool ConfirmUninstall();
|
||||
|
||||
void Uninstalled(string dataFolder, string library);
|
||||
|
||||
void Failed(bool uninstalling, string message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>/S</c>: no dialog, the answers of the silent mode before: the desktop shortcut yes, Febe open means stop, the page
|
||||
/// of WebView2 no, Febe not started. A failure goes to the standard error, for whoever started the installer.
|
||||
/// </summary>
|
||||
internal sealed class SilentInterface(TextWriter errors) : ISetupInterface
|
||||
{
|
||||
public bool? Welcome(string version, string? installedVersion, string installFolder) => true;
|
||||
|
||||
public bool RetryWhenFebeIsOpen(bool uninstalling) => false;
|
||||
|
||||
public void RunWithProgress(string version, string installFolder, Action<Action<double>> work) => work(_ => { });
|
||||
|
||||
public bool OfferWebView2Page() => false;
|
||||
|
||||
public bool Installed() => false;
|
||||
|
||||
public bool ConfirmUninstall() => true;
|
||||
|
||||
public void Uninstalled(string dataFolder, string library)
|
||||
{
|
||||
}
|
||||
|
||||
public void Failed(bool uninstalling, string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
errors.WriteLine((uninstalling ? Texts.UninstallFailed : Texts.InstallFailed) + ": " + message);
|
||||
errors.Flush();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// No one is reading: the exit code says it.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The steps of the installer and of the uninstaller, in the order they always had: first page, Febe closed, copy,
|
||||
/// WebView2, last page; for the uninstaller: a copy of itself in %TEMP% (an executable cannot delete itself),
|
||||
/// confirmation, Febe closed, removal, where the data stayed.
|
||||
/// </summary>
|
||||
internal sealed class SetupFlow(ISystemAccess system, Locations locations, ISetupInterface ui)
|
||||
{
|
||||
private readonly SetupActions _actions = new(system, locations);
|
||||
|
||||
/// <summary>The installer: <paramref name="packagePath"/> is this program, with Febe.exe inside.</summary>
|
||||
public int Install(string packagePath, PackageInfo package, CommandLine line)
|
||||
{
|
||||
var folder = line.InstallFolder ?? locations.DefaultInstallFolder;
|
||||
var desktop = ui.Welcome(package.Version, _actions.InstalledVersion(), folder);
|
||||
if (desktop is null)
|
||||
{
|
||||
return ExitCodes.Cancelled;
|
||||
}
|
||||
|
||||
if (!WaitUntilFebeIsClosed(folder, uninstalling: false, line.Silent))
|
||||
{
|
||||
return line.Silent ? ExitCodes.Failed : ExitCodes.Cancelled;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ui.RunWithProgress(package.Version, folder, progress =>
|
||||
_actions.Install(new InstallRequest(packagePath, package, folder, desktop.Value), progress));
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException)
|
||||
{
|
||||
ui.Failed(uninstalling: false, Texts.Failure(ex));
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
// WebView2: without it Febe cannot show anything. Febe says it too on its first start.
|
||||
if (_actions.WebView2Version() is null && ui.OfferWebView2Page())
|
||||
{
|
||||
system.OpenAddress(Product.WebView2Page);
|
||||
}
|
||||
|
||||
if (ui.Installed())
|
||||
{
|
||||
try
|
||||
{
|
||||
system.Start(Path.Combine(folder, Product.Executable), [], folder);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.ComponentModel.Win32Exception or InvalidOperationException or IOException)
|
||||
{
|
||||
// Febe is installed all the same; it opens from the Start menu.
|
||||
}
|
||||
}
|
||||
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The uninstaller. Started from the program folder (<paramref name="selfPath"/> is «Disinstalla Febe.exe» there), it
|
||||
/// copies itself into %TEMP%, starts the copy and ends; the copy waits for it, then does the work and can delete
|
||||
/// the original.
|
||||
/// </summary>
|
||||
public int Uninstall(string selfPath, CommandLine line)
|
||||
{
|
||||
if (line.UninstallFolder is null)
|
||||
{
|
||||
var installFolder = Path.GetDirectoryName(Path.GetFullPath(selfPath))!;
|
||||
Directory.CreateDirectory(locations.Temp);
|
||||
var copy = Path.Combine(locations.Temp, $"{Product.UninstallerCopyPrefix}{Environment.ProcessId}.exe");
|
||||
File.Copy(selfPath, copy, overwrite: true);
|
||||
system.Start(copy, [.. line.PassOn(), "/_?=" + installFolder, $"/ATTENDI={Environment.ProcessId}"], locations.Temp);
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
|
||||
if (line.WaitFor is { } parent)
|
||||
{
|
||||
system.WaitForExit(parent, TimeSpan.FromSeconds(30));
|
||||
}
|
||||
|
||||
var folder = line.UninstallFolder;
|
||||
if (!ui.ConfirmUninstall())
|
||||
{
|
||||
return ExitCodes.Cancelled;
|
||||
}
|
||||
|
||||
if (!WaitUntilFebeIsClosed(folder, uninstalling: true, line.Silent))
|
||||
{
|
||||
return line.Silent ? ExitCodes.Failed : ExitCodes.Cancelled;
|
||||
}
|
||||
|
||||
// Read before anything is removed, to say at the end where the data stayed.
|
||||
var dataFolder = _actions.DataFolder();
|
||||
try
|
||||
{
|
||||
_actions.Uninstall(folder);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
ui.Failed(uninstalling: true, Texts.Failure(ex));
|
||||
return ExitCodes.Failed;
|
||||
}
|
||||
|
||||
ui.Uninstalled(dataFolder, locations.Library);
|
||||
return ExitCodes.Done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies of the uninstaller left in %TEMP% by earlier uninstallations (a running program cannot delete itself):
|
||||
/// removed when they are no longer running. Never anything else.
|
||||
/// </summary>
|
||||
public static void RemoveOldUninstallerCopies(Locations locations, string? selfPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(locations.Temp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var copy in Directory.EnumerateFiles(locations.Temp, Product.UninstallerCopyPrefix + "*.exe"))
|
||||
{
|
||||
if (selfPath is null || !string.Equals(Path.GetFullPath(copy), Path.GetFullPath(selfPath), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Package.TryDelete(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private bool WaitUntilFebeIsClosed(string folder, bool uninstalling, bool silent)
|
||||
{
|
||||
while (SetupActions.IsFebeOpen(folder))
|
||||
{
|
||||
if (silent)
|
||||
{
|
||||
ui.Failed(uninstalling, Texts.FebeOpenSilent);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ui.RetryWhenFebeIsOpen(uninstalling))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
namespace Febe.Installer;
|
||||
|
||||
/// <summary>What the installer and the uninstaller say, in Italian (glossary: appendix D of the spec).</summary>
|
||||
internal static class Texts
|
||||
{
|
||||
public const string InstallTitle = "Installazione di Febe";
|
||||
|
||||
public const string UninstallTitle = "Disinstallazione di Febe";
|
||||
|
||||
public const string Damaged = "Il programma di installazione è rovinato o incompleto: scaricalo di nuovo.";
|
||||
|
||||
public const string NoPackage = "Questo programma non contiene Febe: usa Febe-Setup-<versione>.exe dalla pagina delle release.";
|
||||
|
||||
public const string WindowsOnly = "Il programma di installazione di Febe gira solo su Windows.";
|
||||
|
||||
public const string Install = "Installa";
|
||||
|
||||
public const string Cancel = "Annulla";
|
||||
|
||||
public const string Retry = "Riprova";
|
||||
|
||||
public const string Finish = "Fine";
|
||||
|
||||
public const string Wait = "Attendi";
|
||||
|
||||
public const string Uninstall = "Disinstalla";
|
||||
|
||||
public const string OpenPage = "Apri la pagina";
|
||||
|
||||
public const string NotNow = "Non ora";
|
||||
|
||||
public const string DesktopShortcut = "Crea un collegamento a Febe sul desktop";
|
||||
|
||||
public const string RunFebe = "Apri Febe adesso";
|
||||
|
||||
public static string Welcome(string version, string? installedVersion) =>
|
||||
installedVersion is null ? $"Installazione di Febe {version}" : $"Aggiornamento di Febe alla versione {version}";
|
||||
|
||||
public static string WelcomeText(Locations locations, string installFolder, string? installedVersion)
|
||||
{
|
||||
var text =
|
||||
"Febe è l'archivio personale di foto, video e storie da Instagram.\n\n"
|
||||
+ $"Verrà installato solo per te, in {installFolder}: non servono permessi di amministratore.\n\n"
|
||||
+ $"I dati di Febe (database e sessione del browser) andranno in {locations.DefaultDataFolder}, le foto e i video "
|
||||
+ "nella cartella Immagini\\Febe; le cartelle si possono cambiare dalle Impostazioni.";
|
||||
return installedVersion is null
|
||||
? text
|
||||
: $"Febe {installedVersion} è già installato: il programma si sostituisce, i dati, la libreria e le impostazioni restano dove sono.\n\n" + text;
|
||||
}
|
||||
|
||||
public const string FebeOpen = "Febe è aperto";
|
||||
|
||||
public const string FebeOpenText = "Chiudilo dall'area di notifica (clic destro sull'icona ▸ Esci), poi premi Riprova.";
|
||||
|
||||
public const string FebeOpenSilent = "Febe è aperto: chiudilo dall'area di notifica (clic destro sull'icona ▸ Esci) e riprova.";
|
||||
|
||||
public static string Installing(string version) => $"Installazione di Febe {version} in corso";
|
||||
|
||||
public static string InstallingText(string installFolder) => $"Copia di Febe.exe in {installFolder}…";
|
||||
|
||||
public const string WebView2Missing = "Manca il runtime WebView2 di Microsoft";
|
||||
|
||||
public const string WebView2MissingText =
|
||||
"Febe ha bisogno del runtime WebView2 di Microsoft, che su questo computer non c'è (Windows 11 e quasi tutti i "
|
||||
+ "Windows 10 lo hanno già).\n\nSi installa gratis dalla pagina ufficiale di Microsoft, senza permessi di "
|
||||
+ "amministratore. Vuoi aprirla adesso?";
|
||||
|
||||
public const string Installed = "Febe è installato";
|
||||
|
||||
public const string InstalledText =
|
||||
"Febe si apre in una sua finestra e resta attivo nell'area di notifica, accanto all'orologio.\n\n"
|
||||
+ "Per collegarlo a Instagram: Impostazioni ▸ Collegamento. Non usare insieme Febe per Windows e il contenitore "
|
||||
+ "Docker con lo stesso account.";
|
||||
|
||||
public const string InstallFailed = "L'installazione non è riuscita";
|
||||
|
||||
public const string ConfirmUninstall = "Disinstallare Febe?";
|
||||
|
||||
public const string ConfirmUninstallText =
|
||||
"Il programma Febe verrà tolto da questo computer. I tuoi dati restano dove sono: la disinstallazione non "
|
||||
+ "cancella né la cartella dei dati né la libreria con le foto e i video.";
|
||||
|
||||
public const string Uninstalled = "Febe è stato disinstallato";
|
||||
|
||||
public static string UninstalledText(string dataFolder, string library) =>
|
||||
"I dati di Febe non sono stati toccati:\n\n"
|
||||
+ $"- cartella dei dati: {dataFolder}\n"
|
||||
+ $"- libreria: {library}, o la cartella scelta nelle Impostazioni.\n\n"
|
||||
+ "La cartella dei dati contiene la sessione di Instagram: se non ti serve più, cancellala tu.";
|
||||
|
||||
public const string UninstallFailed = "La disinstallazione non è riuscita";
|
||||
|
||||
public static string Failure(Exception ex) => ex switch
|
||||
{
|
||||
InvalidDataException => ex.Message,
|
||||
UnauthorizedAccessException => $"Windows non permette di scrivere qui: {ex.Message}",
|
||||
_ => ex.Message,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Febe.Installer.Windows;
|
||||
|
||||
/// <summary>The pages of the installer and of the uninstaller, as dialogs of Windows (texts: <see cref="Texts"/>).</summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
internal sealed class DialogInterface(Locations locations) : ISetupInterface
|
||||
{
|
||||
private const int Yes = 100;
|
||||
|
||||
private const int Cancel = TaskDialog.CancelId;
|
||||
|
||||
public bool? Welcome(string version, string? installedVersion, string installFolder)
|
||||
{
|
||||
var (button, desktop) = TaskDialog.Show(Texts.InstallTitle, new DialogPage(
|
||||
Texts.Welcome(version, installedVersion),
|
||||
Texts.WelcomeText(locations, installFolder, installedVersion),
|
||||
[(Yes, Texts.Install), (Cancel, Texts.Cancel)])
|
||||
{
|
||||
Verification = Texts.DesktopShortcut,
|
||||
VerificationChecked = true,
|
||||
});
|
||||
return button == Yes ? desktop : null;
|
||||
}
|
||||
|
||||
public bool RetryWhenFebeIsOpen(bool uninstalling)
|
||||
{
|
||||
var (button, _) = TaskDialog.Show(Title(uninstalling), new DialogPage(
|
||||
Texts.FebeOpen,
|
||||
Texts.FebeOpenText,
|
||||
[(Yes, Texts.Retry), (Cancel, Texts.Cancel)])
|
||||
{
|
||||
Icon = DialogIcon.Warning,
|
||||
});
|
||||
return button == Yes;
|
||||
}
|
||||
|
||||
public void RunWithProgress(string version, string installFolder, Action<Action<double>> work) =>
|
||||
TaskDialog.ShowProgress(Texts.InstallTitle, new DialogPage(
|
||||
Texts.Installing(version),
|
||||
Texts.InstallingText(installFolder),
|
||||
[(Yes, Texts.Wait)]), work);
|
||||
|
||||
public bool OfferWebView2Page()
|
||||
{
|
||||
var (button, _) = TaskDialog.Show(Texts.InstallTitle, new DialogPage(
|
||||
Texts.WebView2Missing,
|
||||
Texts.WebView2MissingText,
|
||||
[(Yes, Texts.OpenPage), (Cancel, Texts.NotNow)])
|
||||
{
|
||||
Icon = DialogIcon.Information,
|
||||
});
|
||||
return button == Yes;
|
||||
}
|
||||
|
||||
public bool Installed()
|
||||
{
|
||||
var (_, run) = TaskDialog.Show(Texts.InstallTitle, new DialogPage(
|
||||
Texts.Installed,
|
||||
Texts.InstalledText,
|
||||
[(Yes, Texts.Finish)])
|
||||
{
|
||||
Verification = Texts.RunFebe,
|
||||
VerificationChecked = true,
|
||||
});
|
||||
return run;
|
||||
}
|
||||
|
||||
public bool ConfirmUninstall()
|
||||
{
|
||||
var (button, _) = TaskDialog.Show(Texts.UninstallTitle, new DialogPage(
|
||||
Texts.ConfirmUninstall,
|
||||
Texts.ConfirmUninstallText,
|
||||
[(Yes, Texts.Uninstall), (Cancel, Texts.Cancel)]));
|
||||
return button == Yes;
|
||||
}
|
||||
|
||||
public void Uninstalled(string dataFolder, string library) =>
|
||||
TaskDialog.Show(Texts.UninstallTitle, new DialogPage(
|
||||
Texts.Uninstalled,
|
||||
Texts.UninstalledText(dataFolder, library),
|
||||
[(Yes, Texts.Finish)])
|
||||
{
|
||||
Icon = DialogIcon.Information,
|
||||
});
|
||||
|
||||
public void Failed(bool uninstalling, string message) =>
|
||||
TaskDialog.Show(Title(uninstalling), new DialogPage(
|
||||
uninstalling ? Texts.UninstallFailed : Texts.InstallFailed,
|
||||
message,
|
||||
[(Yes, Texts.Finish)])
|
||||
{
|
||||
Icon = DialogIcon.Error,
|
||||
});
|
||||
|
||||
private static string Title(bool uninstalling) => uninstalling ? Texts.UninstallTitle : Texts.InstallTitle;
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.Marshalling;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Febe.Installer.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Shortcuts (.lnk) through the ShellLink object of Windows (<c>IShellLinkW</c> and <c>IPersistFile</c>), with the
|
||||
/// COM interop that .NET generates at compile time: it survives trimming and needs no package.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
internal static unsafe partial class ShellLinks
|
||||
{
|
||||
private const uint ClassContextInprocServer = 1;
|
||||
|
||||
private const int ShowNormal = 1;
|
||||
|
||||
private const uint ReadMode = 0;
|
||||
|
||||
private const uint RawPath = 4;
|
||||
|
||||
private static readonly Guid ShellLinkClass = new(0x00021401, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
|
||||
|
||||
private static readonly Guid ShellLinkInterface = new(0x000214F9, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
|
||||
|
||||
private static readonly StrategyBasedComWrappers Wrappers = new();
|
||||
|
||||
/// <summary>Writes <paramref name="shortcut"/>, replacing a shortcut already there.</summary>
|
||||
public static void Create(Shortcut shortcut)
|
||||
{
|
||||
var link = New();
|
||||
link.SetPath(shortcut.Target);
|
||||
link.SetWorkingDirectory(shortcut.WorkingDirectory);
|
||||
link.SetDescription(shortcut.Description);
|
||||
link.SetIconLocation(shortcut.IconPath, shortcut.IconIndex);
|
||||
link.SetShowCmd(ShowNormal);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(shortcut.Path)!);
|
||||
((IPersistFile)link).Save(shortcut.Path, true);
|
||||
}
|
||||
|
||||
/// <summary>Reads back a shortcut: target, working folder and description (for the tests).</summary>
|
||||
public static (string Target, string WorkingDirectory, string Description) Read(string path)
|
||||
{
|
||||
var link = New();
|
||||
((IPersistFile)link).Load(path, ReadMode);
|
||||
var buffer = stackalloc char[1024];
|
||||
link.GetPath(buffer, 1024, 0, RawPath);
|
||||
var target = new string(buffer);
|
||||
link.GetWorkingDirectory(buffer, 1024);
|
||||
var folder = new string(buffer);
|
||||
link.GetDescription(buffer, 1024);
|
||||
return (target, folder, new string(buffer));
|
||||
}
|
||||
|
||||
private static IShellLinkW New()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(CoCreateInstance(in ShellLinkClass, 0, ClassContextInprocServer, in ShellLinkInterface, out var pointer));
|
||||
try
|
||||
{
|
||||
return (IShellLinkW)Wrappers.GetOrCreateObjectForComInstance(pointer, CreateObjectFlags.None);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.Release(pointer);
|
||||
}
|
||||
}
|
||||
|
||||
[LibraryImport("ole32.dll")]
|
||||
private static partial int CoCreateInstance(in Guid classId, nint outer, uint context, in Guid interfaceId, out nint instance);
|
||||
}
|
||||
|
||||
[GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16)]
|
||||
[Guid("000214F9-0000-0000-C000-000000000046")]
|
||||
internal unsafe partial interface IShellLinkW
|
||||
{
|
||||
void GetPath(char* file, int length, nint findData, uint flags);
|
||||
|
||||
void GetIDList(out nint list);
|
||||
|
||||
void SetIDList(nint list);
|
||||
|
||||
void GetDescription(char* name, int length);
|
||||
|
||||
void SetDescription(string name);
|
||||
|
||||
void GetWorkingDirectory(char* directory, int length);
|
||||
|
||||
void SetWorkingDirectory(string directory);
|
||||
|
||||
void GetArguments(char* arguments, int length);
|
||||
|
||||
void SetArguments(string arguments);
|
||||
|
||||
void GetHotkey(out ushort hotkey);
|
||||
|
||||
void SetHotkey(ushort hotkey);
|
||||
|
||||
void GetShowCmd(out int show);
|
||||
|
||||
void SetShowCmd(int show);
|
||||
|
||||
void GetIconLocation(char* iconPath, int length, out int icon);
|
||||
|
||||
void SetIconLocation(string iconPath, int icon);
|
||||
|
||||
void SetRelativePath(string relativePath, uint reserved);
|
||||
|
||||
void Resolve(nint window, uint flags);
|
||||
|
||||
void SetPath(string file);
|
||||
}
|
||||
|
||||
[GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16)]
|
||||
[Guid("0000010b-0000-0000-C000-000000000046")]
|
||||
internal partial interface IPersistFile
|
||||
{
|
||||
void GetClassID(out Guid classId);
|
||||
|
||||
[PreserveSig]
|
||||
int IsDirty();
|
||||
|
||||
void Load(string fileName, uint mode);
|
||||
|
||||
void Save(string? fileName, [MarshalAs(UnmanagedType.Bool)] bool remember);
|
||||
|
||||
void SaveCompleted(string fileName);
|
||||
|
||||
void GetCurFile(out nint fileName);
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Febe.Installer.Windows;
|
||||
|
||||
/// <summary>The standard icons of the dialog of Windows.</summary>
|
||||
internal enum DialogIcon
|
||||
{
|
||||
None = 0,
|
||||
Warning = 0xFFFF,
|
||||
Error = 0xFFFE,
|
||||
Information = 0xFFFD,
|
||||
}
|
||||
|
||||
/// <summary>One page of a dialog: texts, buttons (the first is the default) and the check box at the bottom.</summary>
|
||||
internal sealed record DialogPage(string Instruction, string Content, IReadOnlyList<(int Id, string Text)> Buttons)
|
||||
{
|
||||
public DialogIcon Icon { get; init; }
|
||||
|
||||
/// <summary>The text of the check box at the bottom, null for none.</summary>
|
||||
public string? Verification { get; init; }
|
||||
|
||||
public bool VerificationChecked { get; init; }
|
||||
|
||||
/// <summary>Esc and the close button answer <see cref="TaskDialog.CancelId"/>.</summary>
|
||||
public bool AllowCancel { get; init; } = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The dialog of Windows (<c>TaskDialogIndirect</c> of the common controls, version 6 through the manifest): the
|
||||
/// pages of the installer without a window framework, so the installer can be trimmed and stays small.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
internal static unsafe partial class TaskDialog
|
||||
{
|
||||
public const int CancelId = 2;
|
||||
|
||||
private const int AllowDialogCancellation = 0x0008;
|
||||
private const int VerificationFlagChecked = 0x0100;
|
||||
private const int ShowProgressBar = 0x0200;
|
||||
private const int CallbackTimer = 0x0800;
|
||||
private const int SizeToContent = 0x01000000;
|
||||
|
||||
private const uint Created = 0;
|
||||
private const uint ButtonClicked = 2;
|
||||
private const uint Timer = 4;
|
||||
|
||||
private const uint UserMessage = 0x0400;
|
||||
private const uint ClickButton = UserMessage + 102;
|
||||
private const uint SetProgressBarPosition = UserMessage + 106;
|
||||
private const uint EnableButton = UserMessage + 111;
|
||||
|
||||
private const int Ok = 0;
|
||||
private const int False = 1;
|
||||
|
||||
/// <summary>Shows <paramref name="page"/> and waits: the button pressed and the state of the check box.</summary>
|
||||
public static (int Button, bool Checked) Show(string title, DialogPage page) => Run(title, page, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Shows <paramref name="page"/> with a progress bar while <paramref name="work"/> runs on another thread; its
|
||||
/// only button stays disabled and the dialog closes by itself at the end. The exception of the work comes out of here.
|
||||
/// </summary>
|
||||
public static void ShowProgress(string title, DialogPage page, Action<Action<double>> work)
|
||||
{
|
||||
var state = new ProgressState(work, page.Buttons[0].Id);
|
||||
var handle = GCHandle.Alloc(state);
|
||||
try
|
||||
{
|
||||
Run(title, page with { AllowCancel = false }, ShowProgressBar | CallbackTimer, GCHandle.ToIntPtr(handle));
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.Free();
|
||||
}
|
||||
|
||||
state.Error?.Throw();
|
||||
}
|
||||
|
||||
private static (int Button, bool Checked) Run(string title, DialogPage page, int extraFlags, nint callbackData)
|
||||
{
|
||||
var strings = new List<nint>();
|
||||
nint Text(string? value)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var pointer = Marshal.StringToHGlobalUni(value);
|
||||
strings.Add(pointer);
|
||||
return pointer;
|
||||
}
|
||||
|
||||
var buttons = (Button*)NativeMemory.Alloc((nuint)page.Buttons.Count, (nuint)sizeof(Button));
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < page.Buttons.Count; i++)
|
||||
{
|
||||
buttons[i] = new Button { Id = page.Buttons[i].Id, Text = (char*)Text(page.Buttons[i].Text) };
|
||||
}
|
||||
|
||||
var flags = SizeToContent | extraFlags;
|
||||
if (page.AllowCancel)
|
||||
{
|
||||
flags |= AllowDialogCancellation;
|
||||
}
|
||||
|
||||
if (page.VerificationChecked)
|
||||
{
|
||||
flags |= VerificationFlagChecked;
|
||||
}
|
||||
|
||||
var config = new Config
|
||||
{
|
||||
Size = (uint)sizeof(Config),
|
||||
Flags = flags,
|
||||
WindowTitle = (char*)Text(title),
|
||||
MainIcon = (nint)page.Icon,
|
||||
MainInstruction = (char*)Text(page.Instruction),
|
||||
Content = (char*)Text(page.Content),
|
||||
ButtonCount = (uint)page.Buttons.Count,
|
||||
Buttons = buttons,
|
||||
DefaultButton = page.Buttons[0].Id,
|
||||
VerificationText = (char*)Text(page.Verification),
|
||||
Callback = callbackData == 0 ? null : &ProgressCallback,
|
||||
CallbackData = callbackData,
|
||||
};
|
||||
int pressed;
|
||||
int verified;
|
||||
Marshal.ThrowExceptionForHR(TaskDialogIndirect(&config, &pressed, null, &verified));
|
||||
return (pressed, verified != 0);
|
||||
}
|
||||
finally
|
||||
{
|
||||
NativeMemory.Free(buttons);
|
||||
foreach (var pointer in strings)
|
||||
{
|
||||
Marshal.FreeHGlobal(pointer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static int ProgressCallback(nint window, uint message, nint wParam, nint lParam, nint data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var state = (ProgressState)GCHandle.FromIntPtr(data).Target!;
|
||||
switch (message)
|
||||
{
|
||||
case Created:
|
||||
SendMessageW(window, EnableButton, state.ButtonId, 0);
|
||||
state.Start();
|
||||
break;
|
||||
case Timer:
|
||||
SendMessageW(window, SetProgressBarPosition, state.Percent, 0);
|
||||
if (state.Finished && !state.Closing)
|
||||
{
|
||||
state.Closing = true;
|
||||
SendMessageW(window, EnableButton, state.ButtonId, 1);
|
||||
SendMessageW(window, ClickButton, state.ButtonId, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case ButtonClicked:
|
||||
return state.Finished ? Ok : False;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Nothing may escape into Windows; the work keeps its own error.
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
private sealed class ProgressState(Action<Action<double>> work, int buttonId)
|
||||
{
|
||||
private volatile bool _finished;
|
||||
private volatile int _percent;
|
||||
|
||||
public int ButtonId => buttonId;
|
||||
|
||||
public int Percent => _percent;
|
||||
|
||||
public bool Finished => _finished;
|
||||
|
||||
public bool Closing { get; set; }
|
||||
|
||||
public ExceptionDispatchInfo? Error { get; private set; }
|
||||
|
||||
public void Start() => _ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
work(share => _percent = (int)Math.Clamp(share * 100, 0, 100));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error = ExceptionDispatchInfo.Capture(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_finished = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
private struct Button
|
||||
{
|
||||
public int Id;
|
||||
public char* Text;
|
||||
}
|
||||
|
||||
/// <summary>TASKDIALOGCONFIG of commctrl.h, packed to 1 byte as there.</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
private struct Config
|
||||
{
|
||||
public uint Size;
|
||||
public nint Parent;
|
||||
public nint Instance;
|
||||
public int Flags;
|
||||
public int CommonButtons;
|
||||
public char* WindowTitle;
|
||||
public nint MainIcon;
|
||||
public char* MainInstruction;
|
||||
public char* Content;
|
||||
public uint ButtonCount;
|
||||
public Button* Buttons;
|
||||
public int DefaultButton;
|
||||
public uint RadioButtonCount;
|
||||
public Button* RadioButtons;
|
||||
public int DefaultRadioButton;
|
||||
public char* VerificationText;
|
||||
public char* ExpandedInformation;
|
||||
public char* ExpandedControlText;
|
||||
public char* CollapsedControlText;
|
||||
public nint FooterIcon;
|
||||
public char* Footer;
|
||||
public delegate* unmanaged[Stdcall]<nint, uint, nint, nint, nint, int> Callback;
|
||||
public nint CallbackData;
|
||||
public uint Width;
|
||||
}
|
||||
|
||||
[LibraryImport("comctl32.dll")]
|
||||
private static partial int TaskDialogIndirect(Config* config, int* button, int* radioButton, int* verificationChecked);
|
||||
|
||||
[LibraryImport("user32.dll")]
|
||||
private static partial nint SendMessageW(nint window, uint message, nint wParam, nint lParam);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Febe.Installer.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="ISystemAccess"/> on Windows: the registry of .NET (HKEY_CURRENT_USER for writing, HKEY_LOCAL_MACHINE only
|
||||
/// read), the Shell for the shortcuts, <see cref="Process"/> for the rest.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
internal sealed class WindowsSystem : ISystemAccess
|
||||
{
|
||||
public string? ReadUserString(string key, string name)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.OpenSubKey(key, writable: false);
|
||||
return opened?.GetValue(name) as string;
|
||||
}
|
||||
|
||||
public int? ReadUserDword(string key, string name)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.OpenSubKey(key, writable: false);
|
||||
return opened?.GetValue(name) is int value ? value : null;
|
||||
}
|
||||
|
||||
public void WriteUserString(string key, string name, string value)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.CreateSubKey(key, writable: true);
|
||||
opened.SetValue(name, value, RegistryValueKind.String);
|
||||
}
|
||||
|
||||
public void WriteUserDword(string key, string name, int value)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.CreateSubKey(key, writable: true);
|
||||
opened.SetValue(name, value, RegistryValueKind.DWord);
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> UserValueNames(string key)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.OpenSubKey(key, writable: false);
|
||||
return opened?.GetValueNames() ?? [];
|
||||
}
|
||||
|
||||
public void DeleteUserValue(string key, string name)
|
||||
{
|
||||
using var opened = Registry.CurrentUser.OpenSubKey(key, writable: true);
|
||||
opened?.DeleteValue(name, throwOnMissingValue: false);
|
||||
}
|
||||
|
||||
public void DeleteUserKeyTree(string key) => Registry.CurrentUser.DeleteSubKeyTree(key, throwOnMissingSubKey: false);
|
||||
|
||||
public string? ReadMachineString(string key, string name)
|
||||
{
|
||||
using var machine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
|
||||
using var opened = machine.OpenSubKey(key, writable: false);
|
||||
return opened?.GetValue(name) as string;
|
||||
}
|
||||
|
||||
public void CreateShortcut(Shortcut shortcut) => ShellLinks.Create(shortcut);
|
||||
|
||||
public void OpenAddress(string address)
|
||||
{
|
||||
using var process = Process.Start(new ProcessStartInfo(address) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
public void Start(string executable, IReadOnlyList<string> arguments, string workingDirectory)
|
||||
{
|
||||
var start = new ProcessStartInfo(executable) { WorkingDirectory = workingDirectory, UseShellExecute = false };
|
||||
foreach (var argument in arguments)
|
||||
{
|
||||
start.ArgumentList.Add(argument);
|
||||
}
|
||||
|
||||
using var process = Process.Start(start);
|
||||
}
|
||||
|
||||
public void WaitForExit(int processId, TimeSpan timeout)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var process = Process.GetProcessById(processId);
|
||||
process.WaitForExit(timeout);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Already ended.
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// Ended while looking at it.
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause(TimeSpan delay) => Thread.Sleep(delay);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Il programma di installazione di Febe: niente permessi di amministratore (installazione per utente; senza questa
|
||||
riga Windows chiederebbe di elevare un programma che ha «Setup» nel nome), i controlli comuni versione 6 (servono
|
||||
alla finestra di dialogo delle attività), consapevole dei DPI per monitor, Windows 10 e 11. -->
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="Febe.Installer" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 e Windows 11 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
Reference in new issue
Block a user