使用AssemblyInfo.cs中的版本初始化build.number

时间:2016-05-24 19:13:43

标签: c# .net teamcity teamcity-9.0 assemblyinfo

问题

如何阅读AssemblyInfo.cs文件中的版本并在TeamCity中将其设置为%build.number%

更多信息

基本上我想阅读本例中的版本(2.2.0):

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("97f3f431-69a7-48c2-8bf8-7ae29075b72e")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: NeutralResourcesLanguage("en-US")]

并将其用作TeamCity项目中的%build.number%

2 个答案:

答案 0 :(得分:1)

你为什么要这样做?通常,要求是另一种方式,即能够将%build.number%设置为AssemblyVersion AssemblyInfo.cs。这可以使用AssemblyInfo Patcher

完成

答案 1 :(得分:-1)

内部版本号应始终与程序集版本周期匹配 通过这种方式,您可以构建在生产中部署的内容。