Share a GlobalAssemblyInfo.cs among projects in a solution

In a project created by Visual Studio, a file called "AssemblyInfo.cs", which describes the assembly generated by the project, will be also automatically created. And it's very common that there is more than one project in a solution. Therefore, there will be many "AssemblyInfo.cs" existing in a solution. However, the contents of these "AssemblyInfo.cs" are more or less the same. It's a type of duplication for sure. We'd better extract all the duplicated code into a global file shared by all the projects.

The image describes the scenario: in a solution, there is a global file called "GlobalAssemblyInfo.cs" which describes assemblies generated by all the projects, and every project holds a reference to the global file. globalassemblyinfo.gif

Steps:

  • Create a file called "GlobalAssemblyInfo.cs";
  • Add the file to the solution as a solution item;
  • Open the global file, Write appropriate codes in it. Sample:
     1 None.gif using  System;
     2 None.gif using  System.Reflection;
     3 None.gif using  System.Runtime.InteropServices;
     4 None.gif
     5 None.gif[assembly : ComVisible( false )]
     6 None.gif[assembly : CLSCompliant( true )]
     7 None.gif[assembly : AssemblyProduct( " dot.gif. " )]
     8 None.gif[assembly : AssemblyCompany( " Company name " )]
     9 None.gif[assembly : AssemblyVersion( " 1.0.0.0 " )]
    10 None.gif #if  DEBUG
    11 None.gif[assembly : AssemblyConfiguration( " Debug " )]
    12 None.gif #else
    13 None.gif[assembly : AssemblyConfiguration( " Release " )]
    14 None.gif #endif
    15 None.gif[assembly : AssemblyCopyright( "" )]
    16 None.gif[assembly : AssemblyTrademark( "" )]
    17 None.gif[assembly : AssemblyCulture( "" )]
  • Open a project file(.csproj, etc.) in a text editor, append the following section to the <Files>/<Include> element.
    1 None.gif < File
    2 None.gif   RelPath  = "GlobalAssemblyInfo.cs"
    3 None.gif  Link  = "..\Common\GlobalAssemblyInfo.cs"
    4 None.gif  SubType  = "Code"
    5 None.gif  BuildAction  = "Compile"
    6 None.gif />
posted on 2005-04-26 13:24  Lin 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/losingmyself/archive/2005/04/26/145554.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值