Mr.*_*kin 2 .net assembly-attributes .net-assembly .net-core
在.NETCore1.1中,接下来的代码
typeof(Program).GetTypeInfo().Assembly.GetCustomAttributes().ToList()
Run Code Online (Sandbox Code Playgroud)
返回自定义程序集属性列表,其中之一是AssemblyTitleAttribute. 默认情况下,此属性值返回项目名称,但如何设置其他值?
尝试按照此处AssemblyInfo.cs描述的方式添加程序集信息文件,但出现错误
错误CS0579:重复的“System.Reflection.AssemblyTitleAttribute”属性
现在属性可以在.csproj或 using中定义AssemblyInfo.cs,但只能使用一处,否则会生成“重复”错误。
如果要使用AssemblyInfo.cs,请添加以下内容.csproj以避免重复错误:
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
如果您对它的工作原理感兴趣,请查看GenerateAssemblyInfo任务。
否则删除AssemblyInfo.cs以下内容并将其添加到您的.csproj文件中:
<PropertyGroup>
<AssemblyTitle>My library</AssemblyTitle>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |