简体   繁体   中英

Initialize the build.number with the version in the AssemblyInfo.cs

Question

How can I read the version from the AssemblyInfo.cs file and set it as %build.number% in TeamCity?

More Info

Basically I want to read the version (2.2.0) in this example:

// 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")]

and use it as my %build.number% in the TeamCity project

Why do you want to do that? Generally the requirement is the other way around, ie to be able to set %build.number% to AssemblyVersion of AssemblyInfo.cs . And this can be done using AssemblyInfo Patcher

内部版本号应始终与程序集版本周期匹配。这样,您现在就可以在生产环境中部署内部版本了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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