Automatically Increment Minimum Required Version in a ClickOnce Application

Automatically Increment Minimum Required Version in a ClickOnce Application - Hallo sahabat Jendela Dunia Internet Dan Tekhnologi, Pada Artikel yang anda baca kali ini dengan judul Automatically Increment Minimum Required Version in a ClickOnce Application, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan Artikel ClickOnce, Artikel Deployment, Artikel MS Build, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : Automatically Increment Minimum Required Version in a ClickOnce Application
link : Automatically Increment Minimum Required Version in a ClickOnce Application

Baca juga


Automatically Increment Minimum Required Version in a ClickOnce Application

Introduction

ClickOnce deployments make publishing .NET applications simple and easy. One nice feature is forcing the user to update to the latest available version. This can be very important on sensitive applications that require any potential fixes or patches to be immediately sent to the users.

One way to do this is to set the minimum required version on the publish page to the current version. ClickOnce then knows to automatically download the latest version whenever a user goes to run the application. The problem with this can be that you have to remember to increment the value every time you do a publish. This post will make life easier by automating the increase of the minimum required version every time you preform a publish.

We’ll do so by adding an MSBuild event to the project. This post assumes you don’t have any experience with MS build and will introduce you to the relevant concepts; if you’re already familiar with that, feel free to jump ahead to Step 6 and copy and paste the code into your .proj file.

Introduction to Project Editor

1) First, in solution explorer, right click on your project and select unload project

2) Once the project has become unavailable, right click again and select edit [project_name].csproj

  • Note: This unlocks full set of IntelliSense of all the MSBuild features

Introduction to MS Build

3) MS Build notation uses properties with key/value pairs to extract information. We’ll use the notation $(key) in the implementation section to reference the .proj elements in Step 4.

  • ex. Using the property name as an alias, you can use $(OutputPath) to obtain the value for the element <OutputPath>.\bin</OutputPath>. So in this case $(OutputPath) = .\bin

4) We’ll use the following properties generated for a ClickOnce deployment

<MinimumRequiredVersion>1.0.0.6</MinimumRequiredVersion>  
<ApplicationRevision>7</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
  • The ApplicationVersion element specifies the build number. The last value of %2a is set by Visual Studio when the option to “Automatically increment revision with each publish” is checked on. In that case, it substitutes the %2a placeholder with whatever value is in the ApplicationRevision element
  • The MinimumRequiredVersion element is what we’d like to set with each publish so that it automatically increments as well.

5) MSBuild Tasks can be specified in the .proj file and invoked during a build event.

  • FormatVersion is a built-in task for .NET 4.0 and later that formats the ApplicationVersion and ApplicationRevision into a single version number

Implementation

6) Copy and Paste the following code into the opened project file as a child element to the root <Project> element:

<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>
  • This code will take ApplicationVersion and ApplicationRevision as parameters in the Format Version task and will save the output by overwriting the MinimumRequiredVersion with the full publish version

7) Save and reload your project. Every ClickOnce deployment will now automatically update without a prompt with the ability to skip.



Demikianlah Artikel Automatically Increment Minimum Required Version in a ClickOnce Application

Sekianlah artikel Automatically Increment Minimum Required Version in a ClickOnce Application kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel Automatically Increment Minimum Required Version in a ClickOnce Application dengan alamat link https://jendeladuniainternet.blogspot.com/2013/05/automatically-increment-minimum.html

0 Response to "Automatically Increment Minimum Required Version in a ClickOnce Application"

Posting Komentar