The AppLife Update Blog

  • I Think I'll Roll My Own Application Updater

    Auto-updating deployed software is easy right?  I mean come on, how hard can it be to download a file from the internet and replace the old with the new. Why wouldn't I roll my own? I'd knock this out in a day or two.  All I'd need to do is...

    Replace some files

    I'll need to download the new files and replace the old ones.  Well... since my application is running and the files I need to replace are locked I'll need to do something with that.  Let's see, I'll just shadow load the exe.  When the application starts, I'll just copy it to another location and run it from there.  That way when my updater wants to replace it with the new one, it'll work.  I might have problems when I want to add another assembly to my application. rollyourown I guess I'll have to copy all the assemblies when my app starts.  That could get messy, but it's quick and easy.  Moving on...

    I'll need to know when an update is available.  OK, I can just retrieve a little file that will tell me what the current update is.  If the current update is newer than what is on the client, I'll download it and replace the client file with the updated file.  What?  Hmmm.... your right.  This will have to be changed if I ever want to update just part of the install, but I'll sort that out later when I have more time and I actually need to do it.  On to downloading...

    Downloading an update

    Downloading should be easy. The .Net framework gives me the WebClient class, which will make it as easy as pie.  I'll probably want to give my users some feedback and let them cancel.  My updates won't be very big so I don't think I'll need to worry about resuming from a previously failed update.  Everyone has fast internet connections now anyways. What's that?  Proxy servers could be a problem?  Well that'll take some time to sort out, so I'll just auto-detect, and if that fails then those users will just have to download the installer again and update the old fashioned way.  You think I should worry about getting hacked?  Not likely.  After all, we're pretty small and don't have that many users.  If they did though, I better do something to prevent that. That'll take some time to sort out, so I'll worry about it when we get big. Maybe crypto-signing or something... later.  Let's move on to actually updating the client...

    Updating the client system

    This will be super easy.  I'll just launch a little exe that will download the new files and replace the old ones.  What? Permissions might be a problem?  Never mind all that.  My users are all administrators on their machines anyway. What? Vista and Windows 7 doesn't even let administrators replace files everywhere?  Well then my users will just have to install the application somewhere where they do have permissions to replace files, or get someone who does have permissions to update their software.  We'll make a better solution later when we have more time to sort it out...  We can always update the updater later.  What?  I know the updater is running!  I'll just have to shadow launch the updater too so that I can replace it during an update.

    And when the updater fails

    All I am doing is replacing a file or two.  Why would the updater fail?  The user can just tell me which files are replaced and which ones aren't.  Later... when we have more time we can back up the files before we try to replace them or maybe even totally change the way we update the files.  Someday maybe we'll even add some logging so that we can figure out what happened when things go wrong.

    Publishing updates

    We'll just copy the new files to our web server whenever we build a new version so that the updater can download them. That's easy enough.  Yeah your right. Maybe we should compress them or something.

    You know... this sounds like a lot more work than I thought.  It might take me weeks, not days to get this done.  I wonder if there is something I can buy that will do all this?  That would save me a lot of time.

    Posted at 25 February, 2010 | By :Brian Haas | Categories : Application Deployment | Software Updating |