Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Args of setup #296

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Squirrel/IUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface IUpdateManager : IDisposable, IEnableLogger
/// <param name="progress">A Observer which can be used to report Progress -
/// will return values from 0-100 and Complete, or Throw</param>
/// <returns>Completion</returns>
Task FullInstall(bool silentInstall, Action<int> progress = null);
Task FullInstall(bool silentInstall, Action<int> progress = null, string argsOfSetup = null);

/// <summary>
/// Completely uninstalls the targeted app
Expand Down
10 changes: 5 additions & 5 deletions src/Squirrel/UpdateManager.ApplyReleases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ApplyReleasesImpl(string rootAppDirectory)
this.rootAppDirectory = rootAppDirectory;
}

public async Task<string> ApplyReleases(UpdateInfo updateInfo, bool silentInstall, bool attemptingFullInstall, Action<int> progress = null)
public async Task<string> ApplyReleases(UpdateInfo updateInfo, bool silentInstall, bool attemptingFullInstall, Action<int> progress = null, string argsOfSetup = null)
{
progress = progress ?? (_ => { });

Expand All @@ -38,7 +38,7 @@ public async Task<string> ApplyReleases(UpdateInfo updateInfo, bool silentInstal
if (release == null) {
if (attemptingFullInstall) {
this.Log().Info("No release to install, running the app");
await invokePostInstall(updateInfo.CurrentlyInstalledVersion.Version, false, true, silentInstall);
await invokePostInstall(updateInfo.CurrentlyInstalledVersion.Version, false, true, silentInstall, argsOfSetup);
}

return getDirectoryForRelease(updateInfo.CurrentlyInstalledVersion.Version).FullName;
Expand All @@ -55,7 +55,7 @@ public async Task<string> ApplyReleases(UpdateInfo updateInfo, bool silentInstal
var newVersion = currentReleases.MaxBy(x => x.Version).First().Version;
executeSelfUpdate(newVersion);

await this.ErrorIfThrows(() => invokePostInstall(newVersion, attemptingFullInstall, false, silentInstall),
await this.ErrorIfThrows(() => invokePostInstall(newVersion, attemptingFullInstall, false, silentInstall, argsOfSetup),
"Failed to invoke post-install");
progress(75);

Expand Down Expand Up @@ -372,7 +372,7 @@ void executeSelfUpdate(Version currentVersion)
File.Copy(newSquirrel, Path.Combine(targetDir.Parent.FullName, "Update.exe"), true));
}

async Task invokePostInstall(Version currentVersion, bool isInitialInstall, bool firstRunOnly, bool silentInstall)
async Task invokePostInstall(Version currentVersion, bool isInitialInstall, bool firstRunOnly, bool silentInstall, string argsOfSetup)
{
var targetDir = getDirectoryForRelease(currentVersion);
var args = isInitialInstall ?
Expand Down Expand Up @@ -414,7 +414,7 @@ async Task invokePostInstall(Version currentVersion, bool isInitialInstall, bool

if (!isInitialInstall || silentInstall) return;

var firstRunParam = isInitialInstall ? "--squirrel-firstrun" : "";
var firstRunParam = isInitialInstall ? "--squirrel-firstrun " + argsOfSetup : "";
squirrelApps
.Select(exe => new ProcessStartInfo(exe, firstRunParam) { WorkingDirectory = Path.GetDirectoryName(exe) })
.ForEach(info => Process.Start(info));
Expand Down
4 changes: 2 additions & 2 deletions src/Squirrel/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public async Task<string> ApplyReleases(UpdateInfo updateInfo, Action<int> progr
return await applyReleases.ApplyReleases(updateInfo, false, false, progress);
}

public async Task FullInstall(bool silentInstall = false, Action<int> progress = null)
public async Task FullInstall(bool silentInstall = false, Action<int> progress = null, string argsOfSetup = null)
{
var updateInfo = await CheckForUpdate();
await DownloadReleases(updateInfo.ReleasesToApply);

var applyReleases = new ApplyReleasesImpl(rootAppDirectory);
await acquireUpdateLock();

await applyReleases.ApplyReleases(updateInfo, silentInstall, true, progress);
await applyReleases.ApplyReleases(updateInfo, silentInstall, true, progress, argsOfSetup);
}

public async Task FullUninstall()
Expand Down
6 changes: 4 additions & 2 deletions src/Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ int main(string[] args)
AnimatedGifWindow.ShowWindow(TimeSpan.FromSeconds(4), animatedGifWindowToken.Token, progressSource);
}

Install(silentInstall, progressSource, Path.GetFullPath(target)).Wait();
string filePath = target.Split(new char[] { ' ' }, 2)[0];
string argsOfSetup = target.Split(new char[] { ' ' }, 2)[1];
Install(silentInstall, progressSource, Path.GetFullPath(filePath), argsOfSetup).Wait();
animatedGifWindowToken.Cancel();
break;
case UpdateAction.Uninstall:
Expand Down Expand Up @@ -160,7 +162,7 @@ int main(string[] args)
return 0;
}

public async Task Install(bool silentInstall, ProgressSource progressSource, string sourceDirectory = null)
public async Task Install(bool silentInstall, ProgressSource progressSource, string sourceDirectory = null, string argsOfSetup = null)
{
sourceDirectory = sourceDirectory ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var releasesPath = Path.Combine(sourceDirectory, "RELEASES");
Expand Down