自动增加“最小所需版本",以增加其数量.在ClickOnce部署中? [英] Automatically increment "minimum required version" in a ClickOnce deployment?

查看:57
本文介绍了自动增加“最小所需版本",以增加其数量.在ClickOnce部署中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以自动将ClickOnce部署中的最低要求版本"字段递增为始终等于当前内部版本号?基本上,我一直希望在启动时自动更新我的部署.

我怀疑我将需要一些构建前/构建后事件,但我希望有一种更简单的方法.

解决方案

回答这个问题可能有点晚了,但是我发现很难在google上找到解决方案,但最终弄清楚了,以为我可以分享. /p>

对于MSBuild版本4(VS2010和VS2012),可以通过插入以下目标来实现:

  <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>

$(ApplicationVersion)是与您可以在VS IDE的项目的发布"窗口中手动设置的相同设置,修订部分设置为星号. $(ApplicationRevision)是用于发布版本的实际修订. FormatVersion任务是内置的MSBuild任务,可将二者格式化为单个完整的版本号.

这会将最低要求版本"设置为与发布版本"相同,因此确保用户将始终安装新的部署,即没有跳过更新的选项.

当然,如果您不想将最低要求的版本设置为发布版本,并且想要使用其他源属性,那么直接修改目标就可以了,但是原理是一样的.

Is there a way to automatically increment the "minimum required version" fields in a ClickOnce deployment to always equal the current build number? Basically, I always want my deployment to be automatically updated at launch.

I suspect I'm going to need a some pre-/post-build events, but I hope there's an easier way.

解决方案

I may be a little late with answering this one but I found it difficult to find the solution on google but eventually figured it out so thought I would share.

With MSBuild version 4 (VS2010 and VS2012) this can be achieved by inserting the following target:

  <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>

The $(ApplicationVersion) is the same setting that you can set manually in the project's Publish window in the VS IDE, with the revision part set to an asterisk. The $(ApplicationRevision) is the actual revision being used for the published version. The FormatVersion task is a built-in MSBuild task that formats the two into a single full version number.

This will set the 'Minimum Required Version' to be the same as the 'Publish Version' therefore ensuring that the new deployment will always be installed by users, ie no option to Skip the update.

Of course, if you don't want to set the minimum required version to the publish version and want to use a different source property then it is straight-forward to amend the target, but the principle is the same.

这篇关于自动增加“最小所需版本",以增加其数量.在ClickOnce部署中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆