我在Visual Studio中有一个解决方案,其中包含许多项目和DLL文件,如何在构建之前或之后更改解决方案中所有文件(dll和exe文件)的版本号?
[
[
我在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")]
to:
// 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.*")]
http://theburningmonk.com/2010/03/net-tips-use-a-shared-assemblyinfo-cs-for-your-solution/
EXE
一起构建的 DLL
都是具有自己的 AssemblyInfo 类的单独程序集。您确定要所有依赖的 DLL
具有相同的版本号吗?当这些 DLL
用于具有自己版本号的不同 EXE
时会发生什么?版本适用于程序集,而不是应用程序(一般而言)。 - Kritner
SharedAssemblyInfo.cs
的文件,并在每个项目中链接它,这样在一个地方更改它会同时更改所有项目的内容。 - Ron Beyer