4

I have a Console application (executable) written in C# .Net that users download and run locally. The users download a zip and extract it to a local directory and run (using command line parameters) via the command line from that location.

Since users will not check for new version I need a way for the executable to check for a newer version of itself and automatically download it and overwrite itself (or at least notify the user).

I have looked at the possibility of using clickonce but that is geared towards windows applications.

All the questions/threads I have looked at only concern auto updating windows applications so are no good for this scenario.

Is there a way (or pattern) to auto update a .Net console app or do I have to write code within the console app to check its version against the server and notify the user?

If its made Clickonce it will break it as a console app - http://social.msdn.microsoft.com/Forums/en-US/8be48914-6563-47cb-9bff-e5e72047bb69/c-console-application-always-is-a-click-once-app

Stumpy1
  • 43
  • 1
  • 6
  • How is the console application executed? From the command-line? – Peter Ritchie Oct 06 '14 at 18:09
  • You could consider https://netsparkle.codeplex.com/. – Vlad Oct 06 '14 at 18:12
  • 4
    The general pattern is to have a secondary application that closes the main exe and downloads the newer version then relaunches the main exe. A program cannot overwrite itself for the most part. – TyCobb Oct 06 '14 at 19:00
  • You can do this with the visual studio publish options. http://msdn.microsoft.com/en-gb/library/1zyc39fb.aspx – kidshaw Oct 06 '14 at 19:29
  • @PeterRitchie - yes it is executed from the commandline. – Stumpy1 Oct 07 '14 at 09:00
  • @Vlad - netsparkle looks like its for windows applications. – Stumpy1 Oct 07 '14 at 09:04
  • @TyCobb - Thats what I was thinking. I may just need to check for new version within th econsole app and notify the user. – Stumpy1 Oct 07 '14 at 09:05
  • @kidshaw - That is the link to clickonce which I have already looked at and only appears to be for windows apps. – Stumpy1 Oct 07 '14 at 09:06
  • Other than a windows instance, what are you deploying too? You can deploy a Console application via click-once in the same way – kidshaw Oct 07 '14 at 09:16
  • As kidshaw said above, there's no reason you can't use ClickOnce for Console Applications. I have some semi-production agents that rely on it to allow updating, so I can guarantee that it works... – Matthew Haugen Oct 07 '14 at 09:45
  • I edited the question to add some clarification as to how users get the console app. I also added a link earlier that shows that clickonce is not an option as the application wont be able to take parameters afterwards - http://social.msdn.microsoft.com/Forums/en-US/8be48914-6563-47cb-9bff-e5e72047bb69/c-console-application-always-is-a-click-once-app I have done a lot of investigation around clickonce (and other auto-update utilities) and have found **no** information about using it for a command line application. If there is a way please provide details. – Stumpy1 Oct 07 '14 at 09:59
  • @stumpy so, ClickOnce is out of the question because you're running the app directly, not going through the ClickOnce shortcut. Short answer is your app will have to check if there's a new version, start an external app to download/update, and then the external app will have to re-run your console app. I'm not sure how viable that is in the command-line. – Peter Ritchie Oct 07 '14 at 14:34
  • @PeterRitchie That's what I was thinking as well. I think I may need to start small and initially just check if there is a newer version somehow and notify the user. – Stumpy1 Oct 07 '14 at 18:18
  • Touching on what @TyCobb said, you're going to need some sort of bootstrapper, and the 2 typical ways to to this is to use ClickOnce or [Shadow Copying](http://msdn.microsoft.com/en-us/library/ms404279(v=vs.110).aspx). The main difference from the original comment is that with shadow copying, the app itself is responsible for acting as the bootstrapper _and_ the executor, so it's not technically a "second application" (all logic is in separate dlls however, so the original exe isn't actually being updated). – Michael Oct 09 '14 at 16:52

0 Answers0