40

From searching I can see this has been asked time and time again, but not adequately enough, so here goes. I'm a hobbyist developer with no budget. A program I've been developing has been in need of regular bugfixes, and me and users are getting tired of having to manually update.

Me, because my current solution of updating a text file through FTP and my download links on the website, and then hoping users will see the "there's an update message", and finally getting them to then be bothered to manually download the update, well quite frankly, is abysmal.

Users, because, well, "Are you ever going to implement auto-update?" "Will there ever be an auto-update feature?" And if I happen to screw up the update process, pitchforks start arriving.

Over the past I have looked into:

  • WinSparkle - No in-app updates, and the DLL is 500 KB. My current solution is a few KBs in the executable and has no in-app updates.
  • .NET Application Update Component - Unfortunately I can't comprehend the documentation.
  • Eduardo Olivera's AutoUpdate - This doesn't appear to support anything other than working with files that aren't in use.
  • wyUpdate - wyBuild isn't free, and while the wyUpdate specification is available, it's simply too complex and time-consuming to go through.
  • AppLife Update - Ditto the last sentence.
  • ClickOnce - Workarounds for implementing launching on startup are massive, horrendous and not worth it for such a simple feature. Publishing is a pain; manual FTP and replace of all files is required for servers without FrontPage Extensions.

It's quite disappointing that the situation on Windows is like this when you've got really nice and simple implementations for Mac OS X like Sparkle.

unrelativity
  • 3,670
  • 6
  • 38
  • 63
  • it would be simpler to create your own auto-updater - use a boot-strapper application to launch your application. The boot-strapper will check if update available and if yes, download & install it. If installation needs admin privileges then you need to have a windows service to run installer. – VinayC Dec 24 '10 at 04:21
  • I sympathize with you completely; that sucks. Have you considered ClickOnce? I haven't personally used it, but I've heard it's really good for this. – Maxim Zaslavsky Dec 24 '10 at 04:51
  • @Maxim Zaslavsky - Yes, I've considered it. I've listed my issues with it in my original post, so you might've missed it. If only it was good. – unrelativity Dec 24 '10 at 05:52
  • whoops, missed that last part. Sorry! Good luck. – Maxim Zaslavsky Dec 24 '10 at 06:50
  • 2
    See also http://stackoverflow.com/questions/691663/auto-update-library-for-net – Ian Mercer Dec 24 '10 at 15:46
  • @a2h Which solution did you pick? You wrote your own updating module? – Nelson Reis Aug 29 '11 at 09:36

8 Answers8

19

Implement it yourself! It will be fun. Create a separate application that only contains update logic i.e., fetch the files online, download them, replace local files, and show that visually to the user.

So your main application could check for updates, and if they exist it would prompt the user with the possibility to update. If the user wants to, it will run the update program, close itself (so the update can happen) and presto.

The only things you need are readily avaliable in C#, FTP access and IO.

Edit: I know it's not something terribly easy, but it's a perfect chance to learn:

  • How to (properly) download files, in an abstracted way that can be extended to ftp, http, etc.
  • How to (properly) do a simple task over many files - copying or overwriting them (this implies error handling).
  • Practice (because there's no "proper" way) to layer and encapsulate a piece of software.
  • How to deal with the OS/other software (antivirus/firewall/etc) not cooperating.

These are all things we all need to know well - If it takes some weeks to code an updater it means you were needing some weeks of learning. If you don't need to learn, time to hone your skills! If you don't know if you need, time to find out! :)

Note: I know I do need to learn better file and network I/O

Camilo Martin
  • 37,236
  • 20
  • 111
  • 154
  • +1... agree, and it isn't too complicated to add some security and check to make sure it is only going to copy in libraries signed by you. – Beth Lang Dec 24 '10 at 04:33
  • 2
    But then again if it's simple, fun and somewhat generic after implementing a home brew mechanism, then why are these endeavors so largely unsuccessful (i.e. the list of software noted int the question)? I think there's likely more detail when you get into it especially considering your updates need to be delivered to disparate platforms with firewalls, security and AV software, etc. Lots of edge cases I can foresee. – John K Dec 24 '10 at 04:38
  • 31
    I've built such a library, it sounds simple, but found out very quickly it is not, especially if you want to build in some more robust features like having different sources (disk, web, network), different patch mechanisms (full, delta, etc), resumable downloads, working within the various security models of xp, vista, win 7 etc. I'm not trying to dissuade you from rolling your own, but don't write it off as a trivial task either. – Brook Dec 24 '10 at 04:45
  • @Brook +1, not trivial at all. The idea of the question seems to be how to achieve this, the easy (but functional) way. – Gerardo Grignoli Dec 24 '10 at 04:50
  • If you're going to take the time to roll your own (which, I agree, could be both a fun and instructive, while at the same time infuriatingly complex, task) why not just spend that time understanding the source code for [wyUpdate](http://wyday.com/wyupdate/)? – Cody Gray - on strike Dec 24 '10 at 05:04
  • @Cody Gray - Do you mean this document? http://wyupdate.googlecode.com/files/wyupdate.file.specifications.pdf I'm personally not very willing to go through 12 pages of bytecode – unrelativity Dec 24 '10 at 05:53
  • 1
    @a2h: Hmm, I see. I didn't realize it was that complicated. I only glanced at the website and noticed that the wyUpdate project was open source. I missed the part where you either buy wyBuild to create updates or cry yourself to sleep at night. – Cody Gray - on strike Dec 24 '10 at 06:03
  • 3
    Writing your a *good* auto-updater yourself will probably take longer than either adapting wyupdate or writing an update generator for it. I wrote a bad one for one of my projects, and I wouldn't do that again. There is so much to get wrong. In particular the security and shimming stuff of vista+ make it a pain to get it right. – CodesInChaos Dec 24 '10 at 09:39
  • The world doesn't need more bad auto updaters... If this is the kind of problem that interests you contributing to one of the already existing open source updaters is a better use of time IMO. – Yaur Jun 13 '12 at 04:34
  • @Yaur you don't take into account the fun of re-inventing the wheel. Sure, if I needed one now, I'd use a out-of-the-box solution, but if I had some spare time left I'd venture into making my own. Unless of course someone made a pretty good no-fuss one, in which case I'd just improve upon it, but if I have to think about improving an already bloated project (as many are) and probably not in one of my comfort languages, then I'd feel like trying to make my own. What I'm saying is that there's the fun involved. – Camilo Martin Jun 13 '12 at 16:13
7

Should've updated this ages ago, oops!

But anyway, I've been using SparkleDotNET for a while now and it's been working absolutely wonderfully. There's a few little bugs here and there but I've already helped get some of them squashed, and hopefully I'll be able to get rid of the others too :)

For those who have the time to run the publish functionality of Visual Studio, and whose app is relatively self-contained, and doesn't require anything like launching on startup, I'd recommend ClickOnce for sure. MetroTwit uses it and it's got a nice in-app updater interface, so it seems flexible (at least to a certain degree). For launching on startup, it's possible to do so, but methods to do so are quite hacky and don't work that well.

unrelativity
  • 3,670
  • 6
  • 38
  • 63
4

You can try Autoupdater.NET from GitHub I developed it my self and it works very well in my applications. You just have to add one line in your code and it's done. Also, it is open source so you can modify and use as you want.

Ravi Patel
  • 2,136
  • 3
  • 32
  • 48
1

There is also DDay update which is open source and is used by one of my customers. We/they are primarily interested in it in the context of a windows service at it works reasonably well for that.

Yaur
  • 7,333
  • 1
  • 25
  • 36
1

You even can not to develop an external application but implement it as your application's module, e.g. into namespace Update, and use dynamic assembly builder to generate an exe, start it and exit app main, start it again when update will be finished.

Some more info.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
0

For a more powerful solution, you may want to look at Google Omaha. It's what Chrome uses. You can get both in-app and automatic updates in the background when your application isn't running.

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

Try with MD5-Update it is absolutely free and easy no configuration need in your app only add library and publish the files. https://github.com/jrz-soft-mx/MD5-Update/

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
-1

all guys are right specially look at the abatishchev reply.but i think some thing other need that guy forgot it. try to develop your project "modular".put them your code in class library as you can.so during the fix operation replace one of them.think a bout database fix.some time you need to add a column to your database table.what do you do for these cases?

a have developed an update project.in that , i have three kind of fixes. 1- BUG in program operation and need to replace a DDL file 2- Bug in program and need to update currently program executive file 3- bug or change the database and need to execute a sql server query

in a table on web host i put the version history and every time that my app start check for new version.if any update exist check for its type and download it and do the suitable action depend on the update kind and parameters

good luck dude

Ali Foroughi
  • 4,540
  • 7
  • 42
  • 66