.net core自动构建版本号
1. 解决方案中新建 AssemblyInfo.cs 类库
代码如下:
using System.Reflection; 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("GZMultiPlatformTest")] [assembly: AssemblyDescription("GZMultiPlatformTest")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("SAS")] [assembly: AssemblyProduct("SAS 1.0")] [assembly: AssemblyCopyright("Copyright © SAS 2020")] [assembly: AssemblyTrademark("")] [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("CA7543D7-0F0F-4B48-9398-2712098E9324")] // 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("1.0.1.*")]
GarsonZhang www.yesdotnet.com
添加后编译会报错,提示一堆特性重复“System.Reflection.AssemblyTitleAttribute”特性重复
> Error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
> Error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
> Error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
不用理会,继续第二步
2. 配置项目 csproj
修改 项目.csproj ,新增配置
<PropertyGroup> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <Deterministic>false</Deterministic> </PropertyGroup>
GarsonZhang www.yesdotnet.com
修改完后重新编译项目,已经可以成功编译,查看
生成的 dll 属性
自动设置了版本号
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post YES开发框架