diff --git a/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs b/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs index fce86f6..fb96d3c 100644 --- a/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs +++ b/Launcher/WiiCompiled.Setup.Windows/InstallerEngine.cs @@ -22,6 +22,9 @@ internal sealed class InstallerEngine var existing = new Installation(installDirectory); PortableInstallHealing.HealMovedInstall(existing, _reporter); + // Capture this before publishing anything. An existing installation may be repaired or + // updated by this invocation, but those operations must not recreate the user's shortcuts. + var firstInstall = !existing.IsPresent; var previousState = existing.ReadInstallState(); using var scratch = Directory.Exists(installDirectory) ? InstallScratchSpace.CreateInsideInstall(installDirectory, _reporter) @@ -139,7 +142,7 @@ internal sealed class InstallerEngine updatedState.RetroRewindInstalled, candidateRuntimeAssetsFingerprint, remainingCancellation); Publish(staging, installDirectory, canonicalRetroRoot, updatedState, - releaseEntries, remainingCancellation); + releaseEntries, remainingCancellation, createShortcuts: firstInstall); return; } @@ -161,7 +164,8 @@ internal sealed class InstallerEngine await PublishToolkitAndReconcileProductsAsync(existing, staging, workspace, manifest, previousState, options, canonicalRetroRoot, retroCompileInputs, - publishGameAssets: reusableGameAssets is null, cancellationToken); + publishGameAssets: reusableGameAssets is null, createShortcuts: firstInstall, + cancellationToken: cancellationToken); } @@ -186,7 +190,7 @@ internal sealed class InstallerEngine string stagedWorkspace, PayloadManifest manifest, InstallState? previousState, InstallOptions options, string? canonicalRetroRoot, RetroRewindCompileInputs? retroCompileInputs, - bool publishGameAssets, CancellationToken cancellationToken) + bool publishGameAssets, bool createShortcuts, CancellationToken cancellationToken) { var installDirectory = existing.Root; @@ -214,7 +218,8 @@ internal sealed class InstallerEngine if (publishGameAssets) AddComponent(entries, staging, installDirectory, "GameAssets"); Publish(staging, installDirectory, canonicalRetroRoot, state, - entries, cancellationToken, progressPercent: 8, completionPercent: 10); + entries, cancellationToken, progressPercent: 8, completionPercent: 10, + createShortcuts: createShortcuts); _reporter.Progress(InstallStages.BuildBase, "Producing the installed products with the published toolkit...", 11); @@ -277,7 +282,7 @@ internal sealed class InstallerEngine private void Publish(string staging, string installDirectory, string? canonicalRetroRoot, InstallState state, List entries, CancellationToken cancellationToken, - int progressPercent = 95, int completionPercent = 99) + int progressPercent = 95, int completionPercent = 99, bool createShortcuts = false) { entries.Add(InstallTransactionEntry.Directory(Path.Combine(staging, "licenses"), Path.Combine(installDirectory, "licenses"))); @@ -322,7 +327,8 @@ internal sealed class InstallerEngine { ShellIntegration.RegisterUninstaller(installDirectory, state.RetroRewindInstalled); } - ShellIntegration.CreateShortcuts(installDirectory); + if (createShortcuts) + ShellIntegration.CreateShortcuts(installDirectory); } catch (Exception ex) {