1

So i've build an AwesomeApplication.exe with visual studio winforms, it has a public repository with releases.

I'd like to add update checker to the application (notifying the user that new release is available for download).

I can get latest release info with github api: https://developer.github.com/v3/repos/releases/#get-the-latest-release

But the application doesn't "know" which github release tag or version it is, unless i'd manually type that in the application settings (before building it)? and then using the api, compare that hard coded version string with github release tag. That would be possible, but requires bit too much manual work.. wondering that are there other options?

my publish process is:

  • build app in visual studio
  • manually zip the exe
  • manually add release and upload zip to the repository

Solution, modified version of @VonC link:

  • Add visual studio prebuild event to fetch current latest release tag (my prebuild script that launches powershell to access github api: https://gist.github.com/unitycoder/c4c5330ad3494ee5b2344a0a86324a3d )
  • The fetched tag is saved in the project folder as PreviousVersion.txt, which is set as a EmbeddedResource in the project (with CopyToOutput set to "Do Not Copy", as i didnt want extra files to the folder)
  • When user clicks "Check Updates" button in the application, ill read the embedded PreviousVersion.txt and compare it with currently available github release tag using https://developer.github.com/v3/repos/releases/#get-the-latest-release
  • If the strings are different, that means user must be using older version

Small update on that: Actually with that checkup above, the string would be always different, since at compile time the current latest release is, lets say 1.10, while after compile and adding new release, its already 1.11 (and compile time string is the old 1.10). So temporary fix for that is to float or int parse your version tag number, compare if its larger by 0.1 or 1 for example, then show update available.

mgear
  • 1,333
  • 2
  • 22
  • 39
  • You might want to look into a Continuous Integration tool like TravisCI which could perform your tagging for you when you push to master, and maybe also set the release version in some resource file, which your program then uses just like it would a hard coded property. Although this is more work, it makes release management and versioning much easier in the long run. – Zach King Feb 17 '18 at 05:22

1 Answers1

1

You can embed the current version in your exe: see "Embed git commit hash in a .Net dll".

That way, your Application can compare its internal version (based on git describe --long, which includes the closest tag) with the version from the latest release (which is based on a tag as well)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks, that solved it. Used modification of this method https://stackoverflow.com/a/15145121/5452781 and it works fine. – mgear Feb 17 '18 at 10:00