使用MSBuild FileUpdate任务仅更改AssemblyInfo.cs中的修订号

编程入门 行业动态 更新时间:2024-10-19 18:36:32
本文介绍了使用MSBuild FileUpdate任务仅更改AssemblyInfo.cs中的修订号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我只需要更改AssemblyInfo.cs文件的修订号.版本号的格式为 Major.Minor.Build.Revision ,例如1.4.6.0.

I need to change only the revision number of an AssemblyInfo.cs file. The version number is in the format Major.Minor.Build.Revision e.g. 1.4.6.0.

当前,我使用FileUpdate任务(从 MSBuild社区任务项目)来更改版本,以下正则表达式:

Currently I change the version with the FileUpdate task (from the MSBuild Community Tasks Project) and the following regex:

<FileUpdate Files="@(AssemblyResult)" Regex='(\[\s*assembly:\s*AssemblyVersion\(\s*"[^\.]+\.[^\.]+)\.([^\.]+)(\.)([^\.]+)("\)\s*\])' ReplacementText='[assembly: AssemblyVersion("$(AssemblyMajorNumber).$(AssemblyMinorNumber).$(AssemblyBuildNumber).$(Revision)")]' />

现在,我只需要更新修订号,而保留主要,次要和内部版本不变. 那么,有什么任务要做吗?还是可以用正则表达式来完成?那么正则表达式是什么?

Now I need to update only the revision number and leave major,minor and build unchanged. So, is there any task to do this? Or can it be done with a regex? What would be the regular expression then?

推荐答案

这是怎么回事:

<FileUpdate Files="Properties/AssemblyInfo.cs" Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)" ReplacementText="$1.$2.$3.$(Revision)" />

更多推荐

使用MSBuild FileUpdate任务仅更改AssemblyInfo.cs中的修订号

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

发布评论

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

>www.elefans.com

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