vs2008修改模板-自定义版权信息

vs2008修改模板-自定义版权信息

我们开发的时候习惯在代码顶部加上自己的版权说明。
每次拷贝挺麻烦的,上网查了一下,2003的介绍但不少。但08的模板生成方式好像改变了
后来2005的一篇介绍给了我一点提示。原来模板文件放在common7目录下。
主要分为ProjectTemplates和ItemTemplates,前者生成项目的时候用,后者add new item的时候用
下面就以修改Web项目里的class文件为例。

模板文件位于 D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\Web\CSharp\1033下
(D盘是我的安装目录)
这里面是一大堆.zip文件,我们把需要的文件Class.zip。解压后修改Class.cs,在头部加上
/* ***********************************************
 * author :  $username$
 * email  :  hujiajian@gmail.com
 * function:
 * history:  created by $username$ $time$
 * ***********************************************/
这里$var$ 都是系统的变量,但是我没找到是在哪里定义的,有知道的朋友麻烦告知一下。

修改好后打包回去覆盖原来的Class.zip,然后在visual studuo的命运行下运行 devenv /setup 就可以使用了。
这个命令比较耗时,大概要几分钟,如果要想临时看效果,也可以修改ItemTemplatesCache目录下的相关文件。

最后生成的Class1.cs如下:
/* *******************************************
 * author :  freewind
 * email  :  hujiajian@gmail.com 
 * function: 
 * history:  created by freewind 3/12/2008 10:44:10 PM 
 * *****************************************
*/


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for Class1
/// </summary>

public class Class1
{
    
public Class1()
    
{
        
//
        
// TODO: Add constructor logic here
        
//
    }

}
其他的文件根据需要修改相应的文件即可。这样我们就可以减少很多手工的劳动了。
Tag标签: VS2008,模板
0
0
(请您对文章做出评价)
« 上一篇:李开复:志在千里 能者无疆
» 下一篇:Web Service高级开发(Microsoft开发者)
posted @ 2008-03-13 09:04 Netprawn 阅读(1001) 评论(2)  编辑 收藏 网摘

  回复  引用  查看    
#1楼2009-06-05 11:02 | 汤包      
Parameter Description
clrversion

Current version of the common language runtime (CLR).

GUID [1-10]

A GUID used to replace the project GUID in a project file. You can specify up to 10 unique GUIDs (for example, guid1).

itemname

The name provided by the user in the Add New Item dialog box.

machinename

The current computer name (for example, Computer01).

projectname

The name provided by the user in the New Project dialog box.

registeredorganization

The registry key value from HKLM\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization.

rootnamespace

The root namespace of the current project. This parameter is used to replace the namespace in an item being added to a project.

safeitemname

The name provided by the user in the Add New Item dialog box, with all unsafe characters and spaces removed.

safeprojectname

The name provided by the user in the New Project dialog box, with all unsafe characters and spaces removed.

time

The current time in the format DD/MM/YYYY 00:00:00.

userdomain

The current user domain.

username

The current user name.

year

The current year in the format YYYY.

  回复  引用  查看    
#2楼2009-09-19 14:43 | Rainbow      
但是我没找到是在哪里定义的,有知道的朋友麻烦告知一下。

看下我的博客,http://www.cnblogs.com/yoyozhou/archive/2008/11/29/1343956.html



Locations of visitors to this page