自动增加“最低要求版本"在 ClickOnce 部署中? [英] Automatically increment "minimum required version" in a ClickOnce deployment?

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

问题描述

有没有办法自动增加 ClickOnce 部署中的最低要求版本"字段以始终等于当前内部版本号?基本上,我总是希望我的部署在启动时自动更新.

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.

推荐答案

我可能回答这个问题有点晚了,但我发现在 google 上很难找到解决方案,但最终想通了,所以想分享一下.

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.

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

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>

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

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天全站免登陆