1

I have WPF application with couple of text files and images.

And i want be able to check every time the app start if there is any update for the applicaion.

So i create xml file in my server with the application version and i want that when there is an update a message will be shown to the user if he want to update the application.

This is a good approach to update my application ?

There is something else that make the upgrade?

If it is a good approach, how should i implement the download and the update?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
YosiFZ
  • 7,792
  • 21
  • 114
  • 221

2 Answers2

3

You could publish your application using ClickOnce from Visual Studio. Does it all automatically.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • 2
    Yeah OP probably should have Googled this or something. ClickOnce is a natural fit. – ta.speot.is Oct 16 '13 at 07:32
  • But when i try to do it it create for me an application that start from the web, i want something that make a setup on the computer – YosiFZ Oct 16 '13 at 07:33
  • +1 but you're not _limited_ to ClickOnce to automatically update it. In general I'm not so excited about ClickOnce approach to deployment (unless application is small enough) – Adriano Repetti Oct 16 '13 at 07:33
  • ClickOnce can generate an installer for you. [Do the "suitable for a CD"](http://msdn.microsoft.com/en-us/library/31kztyey.aspx) bit and put the files on something other than a CD. – ta.speot.is Oct 16 '13 at 07:34
  • @MTA From where should the update be obtained then? Also: ClickOnce is not a WEB technology. You can also use it on the local network or even on the same computer. – Thorsten Dittmar Oct 16 '13 at 07:34
  • @ThorstenDittmar I want the first install will be from a setup.exe for example and the update will be from a server. it's possible with clickOnce? i just start to readin microsoft msdn for it. – YosiFZ Oct 16 '13 at 07:39
  • From the "Do the suitable for the CD" bits: *If the application will check for updates, click The application will check for updates from the following location and enter the location where updates will be posted. This can be a file location, Web site, or FTP server.* Lead a horse to water... – ta.speot.is Oct 16 '13 at 07:43
  • @ta.speot.is I noticed that if i have some files in my project and i publish my app like this so the file won't add to the setup(images and other files) – YosiFZ Oct 16 '13 at 07:46
  • [In various places you can configure "data files" for ClickOnce](http://msdn.microsoft.com/en-us/library/vstudio/dd465298(v=vs.100).aspx). There are other categories of file, too. – ta.speot.is Oct 16 '13 at 07:48
  • @ta.speot.is I noticed that the install is to AppData folder.There is any way to install to Program files? – YosiFZ Oct 16 '13 at 11:52
  • No. ClickOnce applications are installed on a per-user basis. Also, updating an application that's installed in Program Files is not possible without admin rights, so an installed application can only update itself when run by an admin, as normal user accounts are not allowed to modify the Program Files folder. – Thorsten Dittmar Oct 16 '13 at 12:02
  • You can use ClickOnce as a springboard to getting into Program Files but just run with what it does. It pretty much means any user can install your application. And there's plenty of applications that don't install to Program Files (at least by default). Chrome's a good example. – ta.speot.is Oct 16 '13 at 12:08
1

A WPF application is still a .NET application and the same things apply for WinForms, WPF and command-line applications.

There are multiple ways you can have your application auto-update itself:

  • The easiest way is to use ClickOnce to deploy your application to a network share or web site and have users install it from there. The application will always check for new versions published at its original site each time it runs. That's how Fiddler works by the way.
  • A more involved way is to create an installer that checks for updates and add code in your application that detects whether a new version exists and launches the installer. There are many code samples and some Nuget packages that can help with this. Installer tools like NSIS or Wix can support update detection using extensions or scripts.
  • Roll your own is not recommended unless you know what you are doing, as you have to handle locked files, partial/interrupted downloads, dependencies, rollbacks etc
Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236