简体   繁体   English

如何通过TFS 2008使用Team Build从AssemblInfo.cs文件中读取现有程序集版本,递增和更新新版本?

[英]How to read existing assembly version from AssemblInfo.cs files, increment and update the new version using Team Build via TFS 2008?

I need to implement auto-increment for each nightly builds. 我需要为每个夜间构建实现自动增量。

For this, i need to read existing version, increment only the build number and save the incremented build number to assemblyinfo.cs files as well as some custom xml files having the following syntax. 为此,我需要阅读现有版本,仅增加内部版本号,并将增加的内部版本号保存到assemblyinfo.cs文件以及具有以下语法的一些自定义xml文件中。

<?xml version="1.0" encoding="utf-8"?>
<MyProduct>
  <Version>v.3.0.13</Version>
  <Build>3.0.13</Build>
</MyProduct>

I am having trouble to read existing version and build number separately. 我无法分别阅读现有版本和内部版本号。 I could increment build number using the Sdc.Sum Task from Microsoft.Sdc task but there is a problem while trying to read the assembly version. 我可以使用Microsoft.Sdc任务中的Sdc.Sum任务来增加内部版本号,但是尝试读取程序集版本时出现问题。

Kindly help 请帮助

Thanks 谢谢

Got the solution, First i checked out the required .xml and assemblyinfo. 得到了解决方案,首先我签出了所需的.xml和assemblyinfo。 files 档案

the problem was solved using Microsft.SDc.tasks and using the Version task and a proper XPath query, the version was easily read. 使用Microsft.SDc.tasks并使用Version任务和正确的XPath查询解决了该问题,可以轻松读取版本。

using Math.Sum from Microsoft.Sdc or Math.Add from MsBuild Community tasks increment can be performed on any of the single variable that may represent, lets say build number... 使用Microsoft.Sdc中的Math.Sum或MsBuild社区中的Math.Add,可以在可能代表的任何单个变量中执行任意任务增量,比方说内部版本号...

using File.Replace task i was able to change the build number for each nightly build and used a regular expression to match and change version not only in the xml files but also in the assemblyinfo.* files. 使用File.Replace任务,我能够更改每个每晚构建的内部版本号,并使用正则表达式来匹配和更改不仅在xml文件中而且在Assemblyinfo。*文件中的版本。

Finally i checked in the changes 最后,我检查了更改

All the above tasks were performed in the Afterget Target. 以上所有任务均在Afterget目标中执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM