如何获得ClickOnce发布版本以匹配AssemblyInfo.cs文件版本?

编程入门 行业动态 更新时间:2024-10-19 22:29:12
本文介绍了如何获得ClickOnce发布版本以匹配AssemblyInfo.cs文件版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次我在 ClickOnce 中发布应用程序都会得到更新版本号的信息。一个。有没有一种方法可以自动进行此更改以更改AssemblyInfo.cs文件中的版本号(我们所有的错误报告都将查看程序集版本)?

Every time I publish the application in ClickOnce I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at the Assembly Version)?

推荐答案

我们使用Team Foundation Server Team Build,并在TFSBuild.proj的 AfterCompile 目标中添加了一个块,以触发具有我们首选版本号的ClickOnce发布:

We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's AfterCompile target to trigger the ClickOnce publish with our preferred version number:

<MSBuild Projects="$(SolutionRoot)\MyProject\Myproject.csproj" Properties="PublishDir=$(OutDir)\myProjectPublish\; ApplicationVersion=$(PublishApplicationVersion); Configuration=$(Configuration);Platform=$(Platform)" Targets="Publish" />

PublishApplicationVersion 变量由自定义生成MSBuild任务以使用TFS变更集编号,但是您可以使用您自己的自定义任务或现有解决方案,以从AssemblyInfo文件中获取版本号。

The PublishApplicationVersion variable is generated by a custom MSBuild task to use the TFS Changeset number, but you could use your own custom task or an existing solution to get the version number from the AssemblyInfo file.

从理论上讲,这可以在您的项目文件中完成(无论如何,这只是一个MSBuild脚本),但是我建议您不要从开发人员机器上进行部署。

This could theoretically be done in your project file (which is just an MSBuild script anyway), but I'd recommend against deploying from a developer machine.

我确定其他连续集成(CI)解决方案都可以类似地处理。

I'm sure other continuous integration (CI) solutions can handle this similarly.

编辑:抱歉,问题倒退了。从ClickOnce版本号转到AssemblyInfo文件应该是可行的。我确定MSBuild社区任务(上面的链接)具有更新AssemblyInfo文件的任务,因此您只需要一个自定义任务即可从ClickOnce配置XML中提取版本号。

Sorry, got your question backwards. Going from the ClickOnce version number to the AssemblyInfo file should be doable. I'm sure the MSBuild Community Tasks (link above) have a task for updating the AssemblyInfo file, so you'd just need a custom task to pull the version number from the ClickOnce configuration XML.

但是,您也可以考虑更改错误报告,使其也包括ClickOnce发布版本:

However, you may also consider changing your error reporting to include the ClickOnce publish version too:

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { Debug.WriteLine(System.Deployment.Application.ApplicationDeployment. CurrentDeployment.CurrentVersion); }

更多推荐

如何获得ClickOnce发布版本以匹配AssemblyInfo.cs文件版本?

本文发布于:2023-11-07 05:42:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565687.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   如何获得   文件   ClickOnce   AssemblyInfo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!