I updated my ClickOnce application and then when the user runs they are asked if they want to install the new version.
I am working in a highly controlled environment. When an update is available it has to be installed (backwards compatibility with the database is not ensured with old versions).
Another option is to fail the run if skip is pressed (that works fine too).
I need some way to stop them from running an old version of the application.
This article answers your question. I'm pointing you to the article instead of just posting an answer because everything in the article is worth knowing.
http://www.sayedhashimi.com/CategoryView,category,ClickOnce.aspx
The following is the relevant excerpt from the article:
I also found another good article:
ClickOnce: Bringing Ease and Reliability to Smart Client Deployment
This neatly worked for me. Add the following to the project file:
Note that
ApplicationVersion
cannot have a value like1.0.0.*
in the project file and it should be incremented at build time for auto-update to work.If using TeamCity, to increment the version number go to Build Configuration page for your project and set the following System Property:
You can also get MSBuild to increment version by time with something like this:
To force an update on the clients you must set the minimum version field equals to the current version you are deploying, this will force the update whiout "skip" option.
In addition to David's answer, simply install the AutoUpdateProjectsMinimumRequiredClickOnceVersion nuget package in your project. Once you have your project set to check for updates and to use a minimum required version, this will handle making sure the minimum required version always matches your current version (i.e. user's will always be forced to update to the latest version).
It worked me by unchecking The application should check for updates, and the application started updating without prompting the user after two versions.