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

How do I check if the app is installed via Squirrel? #574

Closed
ChargingBulle opened this issue Jan 28, 2016 · 5 comments
Closed

How do I check if the app is installed via Squirrel? #574

ChargingBulle opened this issue Jan 28, 2016 · 5 comments

Comments

@ChargingBulle
Copy link

I want to distribute my app as Squirrel edition and Standalone edition (the standalone wont be able to update)

How can I find out weather an app is installed via Squirrel or not?
My current method of determining isn't very good especially becaue you guys just used System.Execption instead of something like NonSquirrelInstallationException

        UpdateManager updateManager;

        try
        {
            updateManager = new UpdateManager("https://company.com/software/releases");
        }
        catch (Exception exe)
        {
            if (exe.Message.Contains("Update.exe not found"))
            {
                //This isn't an squirrel installed app
                return;
            }

            //throw everything else
            throw exe;
        }   
@ChargingBulle
Copy link
Author

If you don't have a good solution I would like it if you could implement one

@anaisbetts
Copy link
Contributor

var assembly = Assembly.GetEntryAssembly();

var updateDotExe = Path.Combine(
  Path.GetDirectoryName(assembly.Location), 
  '..', 'Update.exe');

var isInstalled = File.Exists(updateDotExe);

@ChargingBulle
Copy link
Author

oh thank you

kenbailey pushed a commit to kenbailey/Squirrel.Windows that referenced this issue Mar 26, 2016
kenbailey pushed a commit to kenbailey/Squirrel.Windows that referenced this issue Mar 26, 2016
anaisbetts added a commit that referenced this issue Mar 30, 2016
@quasarea
Copy link

quasarea commented Jul 9, 2019

It looks like this does the job:

var updates = await updateManager.CheckForUpdate();
if (updates.CurrentlyInstalledVersion == null) { 
  //Seems like this is not a squirrel installation, running within VisualStudio perhaps?
  MessageBox.Show("Unknown current version - possibly application was not installed correctly");
} else if (updates.ReleasesToApply.Any()) {
  //Squirrel installation with updates to apply
  await updateManager.DownloadReleases(updates.ReleasesToApply);
  await updateManager.ApplyReleases(updates);
  await updateManager.UpdateApp();
}

@BreakPointSoftware
Copy link

It looks like this does the job:

var updates = await updateManager.CheckForUpdate();
if (updates.CurrentlyInstalledVersion == null) { 
  //Seems like this is not a squirrel installation, running within VisualStudio perhaps?
  MessageBox.Show("Unknown current version - possibly application was not installed correctly");
} else if (updates.ReleasesToApply.Any()) {
  //Squirrel installation with updates to apply
  await updateManager.DownloadReleases(updates.ReleasesToApply);
  await updateManager.ApplyReleases(updates);
  await updateManager.UpdateApp();
}

This is a more reliable way to check, although both are problematic as update.exe can be present if the application is not installed (for example running in visual studio). Although update.exe is present, other dependent files are not (for example the releases file) if not 'installed'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants