NETCore1.1中如何设置AssemblyTitleAttribute
How to set AssemblyTitleAttribute in NETCore1.1
在 .NETCore1.1 中,下一个代码
typeof(Program).GetTypeInfo().Assembly.GetCustomAttributes().ToList()
returns 自定义程序集属性列表,其中之一是 AssemblyTitleAttribute
。默认情况下,此属性值 returns 项目名称,但如何设置任何其他值?
试图添加程序集信息文件AssemblyInfo.cs
如何描述,但出现错误
error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute'
attribute
现在可以在.csproj
或使用AssemblyInfo.cs
中定义属性,但只能使用一处,否则会产生"Duplicate"错误。
如果要使用AssemblyInfo.cs
,请将以下内容添加到.csproj
中以避免重复错误:
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
如果您对它的工作原理感兴趣,请查看 GenerateAssemblyInfo task。
否则删除 AssemblyInfo.cs
并将以下内容添加到您的 .csproj
文件中:
<PropertyGroup>
<AssemblyTitle>My library</AssemblyTitle>
</PropertyGroup>
在 .NETCore1.1 中,下一个代码
typeof(Program).GetTypeInfo().Assembly.GetCustomAttributes().ToList()
returns 自定义程序集属性列表,其中之一是 AssemblyTitleAttribute
。默认情况下,此属性值 returns 项目名称,但如何设置任何其他值?
试图添加程序集信息文件AssemblyInfo.cs
如何描述
error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
现在可以在.csproj
或使用AssemblyInfo.cs
中定义属性,但只能使用一处,否则会产生"Duplicate"错误。
如果要使用AssemblyInfo.cs
,请将以下内容添加到.csproj
中以避免重复错误:
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
如果您对它的工作原理感兴趣,请查看 GenerateAssemblyInfo task。
否则删除 AssemblyInfo.cs
并将以下内容添加到您的 .csproj
文件中:
<PropertyGroup>
<AssemblyTitle>My library</AssemblyTitle>
</PropertyGroup>