tags:

views:

306

answers:

7

I need to create a patching routine for my application, it's really small but I need to update it daily or weekly how does the xdelta and the others work? i've read around about those but I didn't understand much of it the user shouldn't be prompted at all

A: 

It would really save you a lot of trouble to have a small updater executable included with your application. Your time will be better spent solving other problems.

ChaosPandion
my point was mainly to learn how patching works for future uses
A: 

You can make your function reside in a separate DLL. So you can just replace the DLL instead of patching the whole program. (Assuming Windows as the target platform for a C# program.)

Vlad
my point was mainly to learn how patching works for future uses
+1  A: 

What kind of application is this ? Perhaps you could use clickonce to deploy your application. Clickonce very easily allows you to push updates to your users.

The short story is, Clickonce creates an installation that allows your users to install the application from a web server or a file share, you enable automatic updates, and whenever you place a new version of the app on the server the app will automatically(or ask the user wether to) update the app. The clickonce framework takes care of the rest - fetching the update , figure out which files have changed and need to be downloaded again and performs the update. You can also check/perform the update programatically.

That said, clickonce leaves you with little control over the actual installation procedure, and you have nowhere close to the freedom of building your own .msi.

nos
Also, without a certificate, a rogue user could theoretically include malicious code.
Andrei Tanasescu
Not a bad idea in the C# domain, I like it, +1.
Ninefingers
A: 

Depending on the size of your application, you'd probably have it split up into several dll's, an exe, and other files.

What you could do is have the main program check for updates. If updates are available, the main program would close and the update program would take over - updating old files, creating new ones, and deleting current files as specified by the instructions sent along with a patch file (probably a compressed format such as .zip) downloaded by the updater.

If your application is small (say, a single exe) it would suffice to simply have the updater replace that one exe.


Edit:

Another way to do this would be to (upon compilation of the new exe), compare the new one to the old one, and just send the differences over to the updater. It would then make the appropriate adjustments.

Cam
+2  A: 

I wouldn't go with a patching solution, since it really complicates things when you have a lot of revisions. How will the patching solution handle different versions asking to be updated? What if user A is 10 revisions behind the current revision? Or 100 revisions, etc? It would probably be best to just download the latest exe(s) and dll(s) and replace them.

That said, I think this SO question on silent updates might help you.

Zach Johnson
+1, I agree for simplicity's sake this is a good idea.
Ninefingers
yea but my point isn't to make things simple,i want to learn to do it for future uses while I'm at itanyway if the application is not up to date it just will re-download completely
+1  A: 

There is a solution for efficient patching - it works on all platforms and can run in completely silent mode, without the user noticing anything. On .NET, it provides seamless integration of the update process using a custom UserControl declaratively bound to events from your own UI.

It's called wyUpdate.

While the updating client (wyUpdate) is open source, a paid for wybuild tool is used to build and publish the patches.

Marek
A: 

Ok this post got flagged on meta for the answers given, so I'm going to weigh in on this.

xdelta is a binary difference program that, rather than providing you with a full image, only gives you what has changed and where. An example of a text diff will have + and - signs before lines of text showing you that these have been added or removed in the new version.

There are two ways to update a binary image: replace it using your own program or replace it using some form of package management. For example, Linux Systems use rpm etc to push out updates to packages. In a windows environment your options are limited by what is installed if you're not on a corporate network. If you are, try WSUS and MSI packaging. That'll give you an easier life, or ClickOnce as someone has mentioned.

If you're not however, you will need to bear in mind the following:

  • You need to be an administrator to update anything in certain folders as others have said. I woild strongly encourage you to accept this behaviour.
  • If the user is an administrator, you can offer to check for updates. Then, you can do one of two things. You can download a whole new version of your application and write it over the image on the hard disk (i.e. the file - remember images are loaded into memory so you can re-write your own program file). You then need to tell the user the update has succeeded and reload the program as the new image will be different.
  • Or, you can apply a diff if bandwidth is a concern. Probably not in your case but you will need to know from the client program the two versions to diff between so that the update server gives you the correct patch. Otherwise, the diff might not succeed.

I don't think for your purposes xdelta is going to give you much gain anyway. Just replace the entire image.

Edit if the user must not be prompted at all, just reload the app. However, I would strongly encourage informing the user you are talking on their network and ask permission to do so / enable a manual update mode, otherwise people like me will block it.

Ninefingers