在我以前的工作之一,我们没有给我们的用户选择是否升级;每个版本都以最低版本的形式推出。 然而,如果新版本中出现错误的话,就没有允许用户降级,这确实产生了新的副作用。
To get around this, every time we d publish a version, we would publish the same version a second time to a different location but with the version incremented twice (in other words, with a version that would be higher than the next version we d publish). In the event that we had to roll back, we just needed to copy the version from the secondary location into the primary location and overwrite the main .application file with the one from that specific version.
This does require that you be somewhat disciplined with your versioning, since the whole approach depends on the backup version being higher than the next-higher current version so that ClickOnce thinks it s actually newer. You don t want to make the version too high, since whatever version you publish to replace it must naturally have a version higher than that as well.
例如,它可能采取这样的行动:
Publish version 1.0.0 to primary location and 1.2.0 to backup location
Clients update
Publish version 1.1.0 to primary location and 1.3.0 to backup location
Clients update
Calamity ensues
Copy version 1.2.0 from backup to primary (which is, in reality, version 1.0.0)
Clients update
All is well
Publish version 1.3.0 to primary location and 1.5.0 to backup location
etc.
有两项限制:
- As stated above, your versioning must be disciplined
- An update that gets published after a rollback (version 1.3.0 from above) can t be rolled back from