简体   繁体   English

如何在C#中自动化程序集文件版本

[英]How to automate Assembly File Version in C#

Assembly version can be auto-incremented by specifying it as "1.0.*", which automatically determines build and revision number. 程序集版本可以通过将其指定为“ 1.0。*”来自动增加,这将自动确定内部版本号和修订号。 But in case somebody wants their File version to be the same as the Assembly version, for consistency or other reasons, how can that be achieved without typing it by hand every time? 但是,如果出于一致性或其他原因,有人希望其File版本与Assembly版本相同,那么如何在不每次都手动键入的情况下实现呢? The "1.0.*" method does not work for AssemblyFileVersion. “ 1.0。*”方法不适用于AssemblyFileVersion。

In Properties/AssemblyInfo.cs, just comment out the last line 在Properties / AssemblyInfo.cs中,将最后一行注释掉

[assembly: AssemblyFileVersion("1.0.0.0")]

so the end of the file reads 因此文件末尾读取

// 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("1.0.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

That way the Assembly version number will automatically be assigned as File version as well. 这样,程序集版本号也将自动分配为文件版本。

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

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