[英]How to change Visual Studio 2017 default language version for all projects?
[英]How to change the version of all files in Visual Studio
我在 Visual Studio 中有一个解决方案,它有许多项目和 DLL 文件,如何在构建之前或之后更改解决方案中所有文件(dll 和 exe 文件)的版本?
[
[
可以通过编辑 Assemblyinfo.cs 文件来更改程序集信息,该文件可以在解决方案资源管理器中的项目属性下看到,您可以在此处更改程序集的版本
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("My App Title")]
[assembly: AssemblyDescription("App Description")]
[assembly: AssemblyCompany("My Company Name")]
[assembly: AssemblyProduct("ConsoleApp")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("My Company Trademark")]
[assembly: AssemblyCulture("")]
// 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("513436d3-aa2f-407b-83d2-9268300cc373")]
// 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
//*******Assembly Version can be changed here*********
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
或者
单击“确定”,可以看到您的 AssemblyInfo.cs 文件自动更新
我知道这是一个较旧的问题,但这里有一篇关于在具有多个程序集的解决方案中管理版本的精彩文章。
https://jonthysell.com/2017/01/10/automatically-generating-version-numbers-in-visual-studio/
它显示了在 AssemblyInfo.cs 文件中管理版本控制的三个选项。
我发现选项 3 对我的应用程序最有用,并且最容易维护,因为您在所有程序集之间共享一个文件,并且可以轻松自定义数字以匹配您的特定情况。
正如AssemblyInfo.cs
的评论指出的那样,如果您要更改:
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
到:
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
每次构建后,程序集将获得一个新的构建号/修订版。
从MSDN :
您可以指定所有值,也可以使用星号 ( )接受默认内部版本号、修订号或两者。 例如,[assembly:AssemblyVersion("2.3.25.1")] 表示主要版本为 2,次要版本为 3,内部版本号为 25,修订号为 1。 诸如 [assembly:AssemblyVersion("1.2. ")] 之类的版本号指定 1 作为主要版本,2 作为次要版本,并接受默认的内部版本号和修订版号。 诸如 [assembly:AssemblyVersion("1.2.15.*")] 之类的版本号指定 1 作为主要版本,2 作为次要版本,15 作为内部版本号,并接受默认修订号。 默认的内部版本号每天都会增加。 默认修订号是自当地时间午夜起的秒数(不考虑夏令时的时区调整)除以 2。
共享程序集信息教程:
http://theburningmonk.com/2010/03/net-tips-use-a-shared-assemblyinfo-cs-for-your-solution/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.