Autoupdater.NET.Official 1.4.7

AutoUpdater.NET is a class library that allows .NET developers to easily add auto update functionality to their classic desktop application projects.

There is a newer version of this package available.
See the version list below for details.
Install-Package Autoupdater.NET.Official -Version 1.4.7
dotnet add package Autoupdater.NET.Official --version 1.4.7
<PackageReference Include="Autoupdater.NET.Official" Version="1.4.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autoupdater.NET.Official --version 1.4.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

How it works

AutoUpdater.NET downloads the XML file containing update information from your server. It uses this XML file to get the information about the latest version of the software. If latest version of the software is greater then current version of the software installed on User's PC then AutoUpdater.NET shows update dialog to the user. If user press the update button to update the software then It downloads the update file (Installer) from URL provided in XML file and executes the installer file it just downloaded. It is a job of installer after this point to carry out the update. If you provide zip file URL instead of installer then AutoUpdater.NET will extract the contents of zip file to application directory.

Using the code

XML file

AutoUpdater.NET uses XML file located on a server to get the release information about the latest version of the software. You need to create XML file like below and then you need to upload it to your server.

<?xml version="1.0" encoding="UTF-8"?>
<item>
    <version>2.0.0.0</version>
    <url>http://rbsoft.org/downloads/AutoUpdaterTest.zip</url>
    <changelog>https://github.com/ravibpatel/AutoUpdater.NET/releases</changelog>
    <mandatory>false</mandatory>
</item>

There are two things you need to provide in XML file as you can see above.

  • version (Required) : You need to provide latest version of the application between version tags. Version should be in X.X.X.X format.
  • url (Required): You need to provide URL of the latest version installer file or zip file between url tags. AutoUpdater.NET downloads the file provided here and install it when user press the Update button.
  • changelog (Optional): You need to provide URL of the change log of your application between changelog tags. If you don't provide the URL of the changelog then update dialog won't show the change log.
  • mandatory (Optional): You can set this to true if you don't want user to skip this version. This will ignore Remind Later and Skip options and hide both Skip and Remind Later button on update dialog.
  • args (Optional): You can provide command line arguments for Installer between this tag. You can include %path% with your command line arguments, it will be replaced by path of the directory where currently executing application resides.
  • checksum (Optional): You can provide the checksum for the update file between this tag. If you do this AutoUpdater.NET will compare the checksum of the downloaded file before executing the update process to check the integrity of the file. You can provide algorithm attribute in the checksum tag to specify which algorithm should be used to generate the checksum of the downloaded file. Currently, MD5, SHA1, SHA256, SHA384, and SHA512 are supported.
<checksum algorithm="MD5">Update file Checksum</checksum>

Adding one line to make it work

After you done creating and uploading XML file, It is very easy to add a auto update functionality to your application. First you need to add following line at the top of your form.

using AutoUpdaterDotNET;

Now you just need to add following line to your main form constructor or in Form_Load event. You can add this line anywhere you like. If you don't like to check for update when application starts then you can create a Check for update button and add this line to Button_Click event.

AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.xml");

Start method of AutoUpdater class takes URL of the XML file you uploaded to server as a parameter.

AutoUpdater.Start should be called from UI thread.

Configuration Options

Disable Skip Button

If you don't want to show Skip button on Update form then just add following line with above code.

AutoUpdater.ShowSkipButton = false;

Disable Remind Later Button

If you don't want to show Remind Later button on Update form then just add following line with above code.

AutoUpdater.ShowRemindLaterButton = false;

Ignore previous Remind Later or Skip settings

If you want to ignore previously set Remind Later and Skip settings then you can set Mandatory property to true. It will also hide Skip and Remind Later button. If you set Mandatory to true in code then value of Mandatory in your XML file will be ignored.

AutoUpdater.Mandatory = true;

Enable Error Reporting

You can turn on error reporting by adding below code. If you do this AutoUpdater.NET will show error message, if there is no update available or if it can't get to the XML file from web server.

AutoUpdater.ReportErrors = true;

Run update process without Administrator privileges

If your application doesn't need administrator privileges to replace old version then you can set RunUpdateAsAdmin to false.

AutoUpdater.RunUpdateAsAdmin = false;

Open Download Page

If you don't want to download the latest version of the application and just want to open the URL between url tags of your XML file then you need to add following line with above code.

AutoUpdater.OpenDownloadPage = true;

This kind of scenario is useful if you want to show some information to users before they download the latest version of an application.

Remind Later

If you don't want users to select Remind Later time when they press the Remind Later button of update dialog then you need to add following lines with above code.

AutoUpdater.LetUserSelectRemindLater = false;
AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Days;
AutoUpdater.RemindLaterAt = 2;

In above example when user press Remind Later button of update dialog, It will remind user for update after 2 days.

Proxy Server

If your XML and Update file can only be used from certain Proxy Server then you can use following settings to tell AutoUpdater.NET to use that proxy. Currently, if your Changelog URL is also restricted to Proxy server then you should omit changelog tag from XML file cause it is not supported using Proxy Server.

var proxy = new WebProxy("ProxyIP:ProxyPort", true) 
{
    Credentials = new NetworkCredential("ProxyUserName", "ProxyPassword")
};
AutoUpdater.Proxy = proxy;

Specify where to download the update file

You can specify where you want to download the update file by assigning DownloadPath field as shown below. It will be used for ZipExtractor too.

AutoUpdater.DownloadPath = Environment.CurrentDirectory;

Check updates frequently

You can call Start method inside Timer to check for updates frequently.

WinForms

System.Timers.Timer timer = new System.Timers.Timer
{
    Interval = 2 * 60 * 1000,
    SynchronizingObject = this
};
timer.Elapsed += delegate
{
    AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.xml");
};
timer.Start();

WPF

DispatcherTimer timer = new DispatcherTimer {Interval = TimeSpan.FromMinutes(2)};
timer.Tick += delegate
{
    AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTestWPF.xml");
};
timer.Start();

Handling Application exit logic manually

If you like to handle Application exit logic yourself then you can use ApplicationExiEvent like below. This is very useful if you like to do something before closing the application.

AutoUpdater.ApplicationExitEvent += AutoUpdater_ApplicationExitEvent;

private void AutoUpdater_ApplicationExitEvent()
{
    Text = @"Closing application...";
    Thread.Sleep(5000);
    Application.Exit();
}

How it works

AutoUpdater.NET downloads the XML file containing update information from your server. It uses this XML file to get the information about the latest version of the software. If latest version of the software is greater then current version of the software installed on User's PC then AutoUpdater.NET shows update dialog to the user. If user press the update button to update the software then It downloads the update file (Installer) from URL provided in XML file and executes the installer file it just downloaded. It is a job of installer after this point to carry out the update. If you provide zip file URL instead of installer then AutoUpdater.NET will extract the contents of zip file to application directory.

Using the code

XML file

AutoUpdater.NET uses XML file located on a server to get the release information about the latest version of the software. You need to create XML file like below and then you need to upload it to your server.

<?xml version="1.0" encoding="UTF-8"?>
<item>
    <version>2.0.0.0</version>
    <url>http://rbsoft.org/downloads/AutoUpdaterTest.zip</url>
    <changelog>https://github.com/ravibpatel/AutoUpdater.NET/releases</changelog>
    <mandatory>false</mandatory>
</item>

There are two things you need to provide in XML file as you can see above.

  • version (Required) : You need to provide latest version of the application between version tags. Version should be in X.X.X.X format.
  • url (Required): You need to provide URL of the latest version installer file or zip file between url tags. AutoUpdater.NET downloads the file provided here and install it when user press the Update button.
  • changelog (Optional): You need to provide URL of the change log of your application between changelog tags. If you don't provide the URL of the changelog then update dialog won't show the change log.
  • mandatory (Optional): You can set this to true if you don't want user to skip this version. This will ignore Remind Later and Skip options and hide both Skip and Remind Later button on update dialog.
  • args (Optional): You can provide command line arguments for Installer between this tag. You can include %path% with your command line arguments, it will be replaced by path of the directory where currently executing application resides.
  • checksum (Optional): You can provide the checksum for the update file between this tag. If you do this AutoUpdater.NET will compare the checksum of the downloaded file before executing the update process to check the integrity of the file. You can provide algorithm attribute in the checksum tag to specify which algorithm should be used to generate the checksum of the downloaded file. Currently, MD5, SHA1, SHA256, SHA384, and SHA512 are supported.
<checksum algorithm="MD5">Update file Checksum</checksum>

Adding one line to make it work

After you done creating and uploading XML file, It is very easy to add a auto update functionality to your application. First you need to add following line at the top of your form.

using AutoUpdaterDotNET;

Now you just need to add following line to your main form constructor or in Form_Load event. You can add this line anywhere you like. If you don't like to check for update when application starts then you can create a Check for update button and add this line to Button_Click event.

AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.xml");

Start method of AutoUpdater class takes URL of the XML file you uploaded to server as a parameter.

AutoUpdater.Start should be called from UI thread.

Configuration Options

Disable Skip Button

If you don't want to show Skip button on Update form then just add following line with above code.

AutoUpdater.ShowSkipButton = false;

Disable Remind Later Button

If you don't want to show Remind Later button on Update form then just add following line with above code.

AutoUpdater.ShowRemindLaterButton = false;

Ignore previous Remind Later or Skip settings

If you want to ignore previously set Remind Later and Skip settings then you can set Mandatory property to true. It will also hide Skip and Remind Later button. If you set Mandatory to true in code then value of Mandatory in your XML file will be ignored.

AutoUpdater.Mandatory = true;

Enable Error Reporting

You can turn on error reporting by adding below code. If you do this AutoUpdater.NET will show error message, if there is no update available or if it can't get to the XML file from web server.

AutoUpdater.ReportErrors = true;

Run update process without Administrator privileges

If your application doesn't need administrator privileges to replace old version then you can set RunUpdateAsAdmin to false.

AutoUpdater.RunUpdateAsAdmin = false;

Open Download Page

If you don't want to download the latest version of the application and just want to open the URL between url tags of your XML file then you need to add following line with above code.

AutoUpdater.OpenDownloadPage = true;

This kind of scenario is useful if you want to show some information to users before they download the latest version of an application.

Remind Later

If you don't want users to select Remind Later time when they press the Remind Later button of update dialog then you need to add following lines with above code.

AutoUpdater.LetUserSelectRemindLater = false;
AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Days;
AutoUpdater.RemindLaterAt = 2;

In above example when user press Remind Later button of update dialog, It will remind user for update after 2 days.

Proxy Server

If your XML and Update file can only be used from certain Proxy Server then you can use following settings to tell AutoUpdater.NET to use that proxy. Currently, if your Changelog URL is also restricted to Proxy server then you should omit changelog tag from XML file cause it is not supported using Proxy Server.

var proxy = new WebProxy("ProxyIP:ProxyPort", true) 
{
    Credentials = new NetworkCredential("ProxyUserName", "ProxyPassword")
};
AutoUpdater.Proxy = proxy;

Specify where to download the update file

You can specify where you want to download the update file by assigning DownloadPath field as shown below. It will be used for ZipExtractor too.

AutoUpdater.DownloadPath = Environment.CurrentDirectory;

Check updates frequently

You can call Start method inside Timer to check for updates frequently.

WinForms

System.Timers.Timer timer = new System.Timers.Timer
{
    Interval = 2 * 60 * 1000,
    SynchronizingObject = this
};
timer.Elapsed += delegate
{
    AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTest.xml");
};
timer.Start();

WPF

DispatcherTimer timer = new DispatcherTimer {Interval = TimeSpan.FromMinutes(2)};
timer.Tick += delegate
{
    AutoUpdater.Start("http://rbsoft.org/updates/AutoUpdaterTestWPF.xml");
};
timer.Start();

Handling Application exit logic manually

If you like to handle Application exit logic yourself then you can use ApplicationExiEvent like below. This is very useful if you like to do something before closing the application.

AutoUpdater.ApplicationExitEvent += AutoUpdater_ApplicationExitEvent;

private void AutoUpdater_ApplicationExitEvent()
{
    Text = @"Closing application...";
    Thread.Sleep(5000);
    Application.Exit();
}

Release Notes

* Now using only one request to download the update file.
* Now developer can specify the path where the update file will be downloaded.
* Fixed an issue causing AutoUpdater.NET to crash if the developer doesn't provide installer args in ParseUpdateInfoEvent.
* Now developers can also provide SHA1, SHA256, SHA384, or SHA512 checksum to verify the integrity of the downloaded file.
* Added ability to run update process without administrator privileges.
* Fixed an issue causing AutoUpdater.NET to crash if Dropbox URL was used as the update file URL.

Dependencies

This package has no dependencies.

Showing the top 3 GitHub repositories that depend on Autoupdater.NET.Official:

Repository Stars
ferventdesert/Hawk
visualized crawler & ETL IDE written with C#/WPF
RevoLand/Steam-Library-Manager
Open source utility to manage Steam, Origin and Uplay libraries in ease of use with multi library support
rickbutton/workspacer
a tiling window manager for Windows

Read more about the GitHub Usage information on our documentation.

Version History

Version Downloads Last updated
1.5.8 8,624 11/1/2019
1.5.7 5,044 9/10/2019
1.5.6 2,690 8/21/2019
1.5.5 1,496 8/10/2019
1.5.4 3,378 7/19/2019
1.5.3 3,975 6/7/2019
1.5.2 806 5/29/2019
1.5.1 11,927 3/6/2019
1.5.0 3,043 1/26/2019
1.4.11 15,065 8/2/2018
1.4.10 4,257 6/11/2018
1.4.9 4,122 4/12/2018
1.4.7 3,923 2/10/2018
1.4.6 1,706 12/24/2017
1.4.5 722 12/6/2017
1.4.4 1,057 11/16/2017
1.4.3 4,772 8/5/2017
1.4.2 1,183 6/20/2017
1.4.1 363 6/19/2017
1.4.0 1,106 4/25/2017
1.3.2 6,597 9/3/2016
Show less