Only Recieve ReadyToBeInstalled event

I'm evaluating WyBuild to be our solution for automatic updating. I'm currently testing it and I can't seem to get it to work. I've created a utility class to handle the event listening and and update checking so it doesn't clutter up my main application.

Here's the code:

internal enum UpdateStatus{ UpToDate = 1, UpdateAvailable = 0, Unknown = 2 };

internal class WyUpdateUtilities {

private static AutomaticUpdaterBackend m_auBackend = null; private static UpdateStatus m_upToDate = UpdateStatus.Unknown; public static ManualResetEvent m_recievedStuff = new ManualResetEvent(false);

internal static void Initialize() {

WyUpdateUtilities.m_auBackend = new AutomaticUpdaterBackend { //TODO: set a unique string. // For instance, "appname-companyname" GUID = "{thisisaguidthaticreatedformeandmeonly}",

// With UpdateType set to Automatic, you're still in // charge of checking for updates, but the // AutomaticUpdaterBackend continues with the // downloading and extracting automatically. UpdateType = UpdateType.OnlyCheck,

wyUpdateLocation = @"C:\Users\blahblahblah\wyUpdate.exe", };

WyUpdateUtilities.m_auBackend.BeforeChecking += m_auBackend_BeforeChecking; WyUpdateUtilities.m_auBackend.BeforeDownloading += m_auBackend_BeforeDownloading; WyUpdateUtilities.m_auBackend.BeforeExtracting += m_auBackend_BeforeExtracting; WyUpdateUtilities.m_auBackend.BeforeInstalling += m_auBackend_BeforeInstalling; WyUpdateUtilities.m_auBackend.Cancelled += m_auBackend_Cancelled; WyUpdateUtilities.m_auBackend.CheckingFailed += m_auBackend_CheckingFailed; WyUpdateUtilities.m_auBackend.CloseAppNow += m_auBackend_CloseAppNow; WyUpdateUtilities.m_auBackend.ClosingAborted += m_auBackend_ClosingAborted; WyUpdateUtilities.m_auBackend.DownloadingFailed += m_auBackend_DownloadingFailed; WyUpdateUtilities.m_auBackend.DownloadingFailed +=m_auBackend_DownloadingFailed; WyUpdateUtilities.m_auBackend.ExtractingFailed += m_auBackend_ExtractingFailed; WyUpdateUtilities.m_auBackend.ProgressChanged += m_auBackend_ProgressChanged; WyUpdateUtilities.m_auBackend.ReadyToBeInstalled += m_auBackend_ReadyToBeInstalled; WyUpdateUtilities.m_auBackend.UpdateAvailable += m_auBackend_UpdateAvailable; WyUpdateUtilities.m_auBackend.UpdateFailed += m_auBackend_UpdateFailed; WyUpdateUtilities.m_auBackend.UpdateStepMismatch += m_auBackend_UpdateStepMismatch; WyUpdateUtilities.m_auBackend.UpdateSuccessful += m_auBackend_UpdateSuccessful; WyUpdateUtilities.m_auBackend.UpToDate += m_auBackend_UpToDate;

// Initialize() and AppLoaded() must be called after events have been set. // Note: If there's a pending update to be installed, wyUpdate will be // started, then it will talk back and say "ready to install, // you can close now" at which point your app will be closed. WyUpdateUtilities.m_auBackend.Initialize(); WyUpdateUtilities.m_auBackend.AppLoaded();

WyUpdateUtilities.m_auBackend.ForceCheckForUpdate(true);

}

static void m_auBackend_UpdateSuccessful(object sender, SuccessArgs e) { System.Diagnostics.Trace.WriteLine("Update Successful : " + e.ToString() ); }

static void m_auBackend_UpdateStepMismatch(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Update Step Mismatch"); }

static void m_auBackend_UpdateFailed(object sender, FailArgs e) { System.Diagnostics.Trace.WriteLine("Update Failed " + e.ToString() ); }

static void m_auBackend_ReadyToBeInstalled(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Ready to be installed"); m_recievedStuff.Set(); m_upToDate = UpdateStatus.UpdateAvailable; }

static void m_auBackend_ProgressChanged(object sender, int progress) { System.Diagnostics.Trace.WriteLine("Progress Changed"); }

static void m_auBackend_ExtractingFailed(object sender, FailArgs e) { System.Diagnostics.Trace.WriteLine("Extracting Failed"); }

static void m_auBackend_ClosingAborted(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Closing Aborted"); }

static void m_auBackend_CloseAppNow(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Close App Now"); }

static void m_auBackend_Cancelled(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Cancelled"); }

static void m_auBackend_BeforeInstalling(object sender, BeforeArgs e) { System.Diagnostics.Trace.WriteLine("Before Installing"); }

static void m_auBackend_BeforeExtracting(object sender, BeforeArgs e) { System.Diagnostics.Trace.WriteLine("Before Extracting"); }

static void m_auBackend_BeforeDownloading(object sender, BeforeArgs e) { System.Diagnostics.Trace.WriteLine("Before Downloading"); }

static void m_auBackend_BeforeChecking(object sender, BeforeArgs e) { System.Diagnostics.Trace.WriteLine("Before Checking Update"); }

static void m_auBackend_UpToDate(object sender, SuccessArgs e) { System.Diagnostics.Trace.WriteLine("Software is up to date"); m_recievedStuff.Set(); }

static void m_auBackend_UpdateAvailable(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLine("Software update is available"); m_recievedStuff.Set(); }

static void m_auBackend_DownloadingFailed(object sender, FailArgs e) { System.Diagnostics.Trace.WriteLine("Downloading Update failed"); m_recievedStuff.Set(); }

static void m_auBackend_CheckingFailed(object sender, FailArgs e) { System.Diagnostics.Trace.WriteLine("Checking for Update failed"); m_recievedStuff.Set(); }

}

---The code that calls it, just has this:

WyUpdateUtilities.Initialize();

WyUpdateUtilities.m_recievedStuff.WaitOne(30000);

---When running the test, I don't ever receive the "UpToDate", "BeforeChecking", "CheckingFailed", or "UpdateAvailable" events.

I only receive the "ReadyToBeInstalled" event.

It doesn't matter if it is up to date or not. I go to C:\users\blahblahblah\wyUpdate.exe and run it manually and it reports that an update is available. I cancel the update run the test and only get readytobeinstalled. Then I run the updator, update the app. Run it again and verify it's up to date, then run the test and I get readytobeinstalled again.

I'm sure I'm missing something simple and just need another set of eyes to look at it.

Also, I can't figure out how to get the Version that is already on the machine. I've been reading in the forumns that it is not possible and want to verify that that is true. The WyUpdate GUI knows how to figure it out as it displays in the dialog so I thought the backend would know too.

Thanks

Hey Daniel,

You're only getting ReadyToBeInstalled because you only told the AutomaticUpdaterBackend to go to that point:

UpdateType = UpdateType.OnlyCheck,

If you want to tell it to go all the way, then you have to actually tell it that:

UpdateType = UpdateType.Automatic

Thanks! That works. Is there any documentation on what the different UpdateType values do? Also is it still not possible to get the current version?

Is there any documentation on what the different UpdateType values do? Also is it still not possible to get the current version?

The documentation is in the API (specifically the intellisense).

/// <summary>/// Specifies the update type that the AutomaticUpdater uses./// </summary>public enum UpdateType {    /// <summary>    /// The AutomaticUpdater will check, download, and install the update completely silently.    /// </summary>    Automatic = 0, 


    /// <summary>    /// The AutomaticUpdater will check for and download updatest automatically, then notify the user.    /// </summary>    CheckAndDownload = 1,


    /// <summary>    /// The AutomaticUpdater will only check for updates and notify the user if updates are found.    /// </summary>    OnlyCheck = 2,


    /// <summary>    /// The AutomaticUpdater will do nothing. All checking must be done manually.    /// </summary>    DoNothing = 3}
Also is it still not possible to get the current version?

The only way to do it is to embed the version in your app (typically in AssemblyInfo) and read the version from that.

Thanks for the quick response. Do you have any recommendations on tracking version changes when the new version is only changing configuration files, or should you just reship the executable every version even if there are no changes in it (other than the version changing)?

or should you just reship the executable every version even if there are no changes in it (other than the version changing)?

Well you could either just change the version of your executable and/or you could add version information to your config file.