13

How do I develop my Windows application so it will auto update on the client machine, like Firefox, Skype, etc.?

Is there any simple approach or any open source library which help me to do it just following some steps or a few lines of code?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Thomas
  • 33,544
  • 126
  • 357
  • 626

9 Answers9

9

ClickOnce is what you're searching for.

You might also find these SO questions interesting (which offers some different solutions):

Community
  • 1
  • 1
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
  • 3
    Here is an article against ClickOnce http://www.stevestreeting.com/2013/05/12/friends-dont-let-friends-use-clickonce/ – Jeson Martajaya Feb 04 '14 at 22:18
  • Another drawback of ClickOnce is that it can only update user (not machine-wide) installations. For a list of available update frameworks, you may find https://omaha-consulting.com/best-update-frameworks-for-windows interesting. – Michael Herrmann Jun 23 '20 at 16:38
4

The most popular frameworks are:

  • Google Omaha - This is what Chrome uses. Very powerful.
  • Squirrel - This is used in Electron applications. Easy to use but can't update machine-wide installations. Also, no graphical update notifications.
  • WinSparkle - Gives you graphical update notifications. But less mature than Squirrel.
  • AutoUpdater.NET - Both graphical and silent updates. Similar to Squirrel and WinSparkle.

I've taken these links from this article. It goes into more details about the pros and cons of each of the frameworks.

Michael Herrmann
  • 4,832
  • 3
  • 38
  • 53
3

try microsoft clickonce technology

(in MSDN)

Dani
  • 14,639
  • 11
  • 62
  • 110
3

You can use wyUpdate or .NET Application Updater Component

Giorgi
  • 30,270
  • 13
  • 89
  • 125
2

There is also the Update Block in the Ent Lib by msft.

dexter
  • 7,063
  • 9
  • 54
  • 71
2

Use MD5-Update it easy only need add 5 lines at your application, no configuration need in your app only add library and publish the files.

MD5-Update

1. Your need a web server with PHP for publish your files please include updt.exe.

WebServer

2. Add index.php for make list of update files. aviable on github repository https://github.com/jrz-soft-mx/MD5-Update/blob/main/Tools/Tools.zip o create new app with this code.

<?php
$_dat = array();
$_dir=new RecursiveDirectoryIterator(".");
foreach (new RecursiveIteratorIterator($_dir) as $_itm) {
    $_fil = str_replace(".".DIRECTORY_SEPARATOR, "", $_itm);
    if(!is_dir($_fil) && $_fil != "index.php"){     
        $_dat[]=array('StrFil' => "$_fil", 'StrMd5' => strtoupper(md5_file($_fil)), 'lonSiz' => filesize($_fil));
    }
}
echo json_encode($_dat, JSON_UNESCAPED_UNICODE);
?>

enter image description here

3. Add nuget repository at your proyect

PM> Install-Package MD5.Update

4. Call the library when your app stars, with your update folder url, update all files and download your new app on updt folder, for replace your app need updt.exe

string strUrl = "http://yourdomain.com/app/";
if (MD5Update.MD5Update.Check(strUrl, true))
{
    Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"updt.exe", AppDomain.CurrentDomain.FriendlyName + " " + Process.GetCurrentProcess().ProcessName);
    Application.Exit();
}

enter image description here

enter image description here

5. updt.exe for replace the current app with the new app updt folder to app. aviable on github repository https://github.com/jrz-soft-mx/MD5-Update/blob/main/Tools/Tools.zip o create new app with this code.

try
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    List<string> lisArg = Environment.GetCommandLineArgs().ToList();
    if (lisArg.Count < 2)
    {
        MessageBox.Show("Please provide App Excutable Name and Procees name");
        Application.Exit();
        return;
    }
    string strAppName = lisArg[1];
    string strAppProcees = lisArg[2];
    Process[] lisPro = Process.GetProcessesByName(strAppProcees);
    foreach (Process Pro in lisPro)
    {
        if (Pro.Id != Process.GetCurrentProcess().Id)
        {
            Pro.Kill();
            Thread.Sleep(1000);
        }
    }
    string strAppMain = AppDomain.CurrentDomain.BaseDirectory + strAppName;
    string strAppUpdate = AppDomain.CurrentDomain.BaseDirectory + @"updt\" + strAppName;
    if (!File.Exists(strAppMain))
    {
        MessageBox.Show("App Excutable dosent exists");
        Application.Exit();
        return;
    }
    if (!File.Exists(strAppUpdate))
    {
        MessageBox.Show("App Excutable Updated dosent exists");
        Application.Exit();
        return;
    }
    File.Copy(strAppUpdate, strAppMain, true);
    long fileSize = 0;
    FileInfo currentFile = new FileInfo(strAppMain);
    while (fileSize < currentFile.Length)
    {
        fileSize = currentFile.Length;
        Thread.Sleep(1000);
        currentFile.Refresh();
    }
    Process.Start(strAppMain);
}
catch (Exception Ex)
{
    MessageBox.Show("An error ocurred");
    File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"updt_" + DateTime.Now.ToString("yyyyMMddTHHmmss")  + " .txt", Ex.ToString());
    Application.Exit();
}
jrz.soft.mx
  • 151
  • 1
  • 1
  • 11
0

How about System Center 2012 Configuration Manager?

Uri Abramson
  • 6,005
  • 6
  • 40
  • 62
0

While ClickOnce is simple and it resurrected for .NET 5, it still has a lot of limitations, so I found out that nowadays better option exists: you could use included in Windows 10 mechanism for app delivery called AppInstaller by packaging your app in MSIX bundle or package.

I covered my findings related to the topic in this answer

Lev
  • 811
  • 12
  • 13