Making ClickOnce Updates Mandatory?

蹲街弑〆低调 提交于 2019-12-03 02:52:16

Automatic Updates

Choosing a ClickOnce Update Strategy (Making Updates Required)

One options is to set up automatic updates to your software and mark them as required by setting the minimum required version in your deployment manifest. You can set this in the properties dialog in Visual Studio, or through configuration with the following tag: <deployment install="true" minimumRequiredVersion="1.0.0.0">. The minimum required version checks the version of your assembly, and if it is not at least what you specify here it will force an update.

Programmatic Updates

How to: Add On-Demand Programmatic Update

Another option that will allow you more control of when and how often the update occurs is to do the updates programmatically. You can use the ClickOnce API to check for any updates on the deployment server and install them once your application has been run. You can have far more control over what updates should be installed, how they are installed, and how you notify the user of the updates. If your application is generally a long running instance, you could also set up timers to run in the background every so often to do the updates as well.

Here is an example implementation that polls on an interval: Example.

You can also combine the above two update methods.

Denxorz

The "Auto Update Project's Minimum Required ClickOnce Version" project has a nuget package that updates the ClickOnce settings for you.

https://aupmrcov.codeplex.com/ [ archived ]

GitHub:

https://github.com/deadlydog/AutoUpdateProjectsMinimumRequiredClickOnceVersion

Nuget:

https://www.nuget.org/packages/AutoUpdateProjectsMinimumRequiredClickOnceVersion

Simply you can achieve by adding below <target> tag in your project's .csproj file.

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    // Other Tags ...

    <Target Name="AutoSetMinimumRequiredVersion" BeforeTargets="GenerateDeploymentManifest">
        <FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
            <Output PropertyName="MinimumRequiredVersion" TaskParameter="OutputVersion" />
        </FormatVersion>
        <FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
            <Output PropertyName="_DeploymentBuiltMinimumRequiredVersion" TaskParameter="OutputVersion" />
        </FormatVersion>
    </Target>

    // Other Tags ...

</Project>

It will automatically make your each publish/update mandatory without doing any extra stuff.

If you specify minimum required version same as the current publish version, your application will update as soon as clients open it.

1-Just right-click on the project name
2-Select Properties
3-Click Publish (Note publish version)
4-Click on Update button
5-Select "Specify minimum required version for this application"
and
Finally, make version number same as the "Publish Version".

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!