Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically update an application without ClickOnce?

Tags:

c#

deployment

For the project I am working on, I am not allowed to use ClickOnce. My boss wants the program to look "real" (with an installer, etc).

I have installed Visual Studio 2012 Professional, and have been playing around with the InstallShield installer, and it definitely makes nice installers, but I can't figure out how to enable the application to "auto-update" (that is, when it starts up, checks to make sure that it is using the latest version).

I have been asked to make a tiny change to the code - switching an addition to a subtraction, and I don't really want people to have to uninstall the old version, and then have to reinstall the new version every time I make a small change like this.

How can I make the application check for updates, and install them? Or is this not possible (or not easy)?

like image 347
Toadums Avatar asked Oct 08 '12 18:10

Toadums


People also ask

How to Auto update c# Windows application?

In the program that you want to be auto updateable, you just need to call the AutoUpdate function in the Main procedure. The AutoUpdate function will check the version with the one read from a file located in a Web Site/FTP.

How do I manage updates for a ClickOnce application?

With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. Click the Updates button to open the Application Updates dialog box. In the Application Updates dialog box, make sure that the The application should check for updates check box is cleared.


2 Answers

There are a lot of questions already about this, so I will refer you to those.

One thing you want to make sure to prevent the need for uninstallation, is that you use the same upgrade code on every release, but change the product code. These values are located in the Installshield project properties.

Some references:

  • Auto update .NET applications
  • Auto-update library for .NET?
  • Auto update for WinForms application
  • Suggest a method for auto-updating my C# program
  • Automatic update a Windows application
like image 172
JYelton Avatar answered Oct 06 '22 00:10

JYelton


I think you should check the following project at codeplex.com http://autoupdater.codeplex.com/

This sample application is developed in C# as a library with the project name “AutoUpdater”. The DLL “AutoUpdater” can be used in a C# Windows application(WinForm and WPF).

There are certain features about the AutoUpdater:

  1. Easy to implement and use.
  2. Application automatic re-run after checking update.
  3. Update process transparent to the user.
  4. To avoid blocking the main thread using multi-threaded download.
  5. Ability to upgrade the system and also the auto update program.
  6. A code that doesn't need change when used by different systems and could be compiled in a library.
  7. Easy for user to download the update files.

How to use?

In the program that you want to be auto updateable, you just need to call the AutoUpdate function in the Main procedure. The AutoUpdate function will check the version with the one read from a file located in a Web Site/FTP. If the program version is lower than the one read the program downloads the auto update program and launches it and the function returns True, which means that an auto update will run and the current program should be closed. The auto update program receives several parameters from the program to be updated and performs the auto update necessary and after that launches the updated system.

  #region check and download new version program   bool bSuccess = false;   IAutoUpdater autoUpdater = new AutoUpdater();   try   {       autoUpdater.Update();       bSuccess = true;   }   catch (WebException exp)   {       MessageBox.Show("Can not find the specified resource");   }   catch (XmlException exp)   {       MessageBox.Show("Download the upgrade file error");   }   catch (NotSupportedException exp)   {       MessageBox.Show("Upgrade address configuration error");   }   catch (ArgumentException exp)   {       MessageBox.Show("Download the upgrade file error");   }   catch (Exception exp)   {       MessageBox.Show("An error occurred during the upgrade process");   }   finally   {       if (bSuccess == false)       {           try           {               autoUpdater.RollBack();           }           catch (Exception)           {              //Log the message to your file or database           }       }   }   #endregion 
like image 21
Anas Naguib Avatar answered Oct 06 '22 01:10

Anas Naguib