Where's my road?

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  10 Posts :: 0 Stories :: 29 Comments :: 0 Trackbacks

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.

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

Feedback

#1楼 2005-04-26 13:28 birdshome
very good!
  回复  引用    

#2楼 2005-04-26 13:32 gang
goo个呀儿,我看不懂
  回复  引用    

#3楼 2005-04-26 13:34 James      
這樣做有什麼好處呢?
  回复  引用  查看    

#4楼 2005-04-26 13:38 Lin
It can minimize duplication for sure. And It helps us control our solution's version a bit easily, etc...
  回复  引用    

#5楼 2005-04-26 13:59 dudu      
google广告建议使用180px宽度, 现在的宽度影响页面显示。
  回复  引用  查看    

#6楼 2005-04-26 20:41 CsOver
this is very useful! thanks!
  回复  引用    

#7楼 2005-04-27 08:51 Kozen      
我以前从EDRA的代码中学到了这招,但始终不知道如何在IDE中直接实现此操作,即不手工修改工程文件(.csproj)。望赐教,谢谢。
  回复  引用  查看    

#8楼 2005-04-27 09:05 Lin
Perhaps we can't implement that directly from IDE :(
  回复  引用    

#9楼 2005-05-08 12:42 元子
good
  回复  引用    

#10楼 2006-05-30 16:59 shensr      
在Add Existing Item时,Add按钮有个下三角,点击会出来一个菜单“Add As Link”,即可
  回复  引用  查看    

The web application project do not have a project file, so how to add the file ref to a web application? I really want all the dlls built from web application use the global assemblyinfo.
  回复  引用    




发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 145554




相关文章:

相关链接: