3. 增加文档 一旦应用程序被正确构建并且能够正常工作,你应该把一些文档添加到工程上,以便使用你的Starter Kit的开发者能理解应用程序是怎么工作的。例如,你可能为开发者提供了链接以便用一个自由的Amazon web服务帐户注册并且向他说明怎样获得订阅ID来访问该web服务。 你可以添加一个HTML文档或一个普通文本文件到该工程。为简化起见,我把一普通文本文件添加到该工程并且命名它为Documentation.txt(见图8)。 4. 输出模板 在应用程序和文档完成后,现在你已准备好输出该工程了。为了共享你的应用程序,你必须把它放进一个模板中。为此,你可以经由"File"-->"Export Template"菜单项来实现。 然后,你将被要求选择一个模板类型。对于创建Starter Kits,我们选择"Project template"。这个选项模板可用于创建一个表单,类,模块等,而不是一个完整的工程。这个解决方案只有一个工程,所以简单地选择LibraryApp工程(见图9)。然后点击"Next"。 498)this.style.width=498;" border=0> 图9.模板:为了输出你的Starter Kit,你需要为应用程序选择正确的模板类型。
498)this.style.width=498;" border=0> 图10.选项:用正确的选项配置你的Starter Kit。
在下一个对话框中,你可以选取你自己的模板图标(见图10)并命名你的模板为LibraryApp Starter Kit。不选取"Automatically import the template into Visual Studio"选项。由于这是一个方便的选项,在了解如何手工地创建一个Starter Kit时它是很有用的。最后,点击"Finish"。 就是这样!你的模板将在下列文件夹被创建: C:\Documents and Settings\Wei-Meng Lee\My Documents\Visual Studio 2005\My Exported Templates\ 把输入的模板文件放到一个.zip文件中并命名它为LibraryApp Starter Kit.zip。下面你将使用这个.zip文件。 5. 在启动模板时打开特定的文件 记住,你刚创建的模板有一个文档文件。每当有人使用你的模板创建一个工程时,你就要显示这个文件。为此,你需要修改位于文件LibraryApp Starter Kit.zip内的MyTemplate.vstemplate配置文件。 首先,把LibraryApp Starter Kit.zip文件的内容提取到默认文件夹-LibraryApp Starter Kit下。然后,进入到这个LibraryApp Starter Kit文件夹并且使用记事本来编辑这个MyTemplate.vstemplate文件。 特别地,插入下面行(以加粗显示的): <VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"> <TemplateData> <Name>LibraryApp Starter Kit</Name> <Description><No description available></Description> <ProjectType>VisualBasic</ProjectType> <ProjectSubType> </ProjectSubType> <SortOrder>1000</SortOrder> <CreateNewFolder>true</CreateNewFolder> <DefaultName>LibraryApp Starter Kit</DefaultName> <ProvideDefaultName>true</ProvideDefaultName> <LocationField>Enabled</LocationField> <EnableLocationBrowseButton>true</EnableLocationBrowseButton> <Icon>__TemplateIcon.ico</Icon> </TemplateData> <TemplateContent> <Project TargetFileName="LibraryApp.vbproj" File="LibraryApp.vbproj" ReplaceParameters="true"> <ProjectItem ReplaceParameters="true" TargetFileName="app.config">app.config</ProjectItem> <ProjectItem ReplaceParameters="true" TargetFileName="Documentation.txt">Documentation.txt</ProjectItem> <ProjectItem ReplaceParameters="false" OpenOrder="10" OpenInWebBrowser="true">Documentation.txt</ProjectItem> <ProjectItem ReplaceParameters="true" TargetFileName="Form1.vb">Form1.vb</ProjectItem> <ProjectItem ReplaceParameters="true" TargetFileName="Form1.Designer.vb">Form1.Designer.vb</ProjectItem> ... |
一旦修改完MyTemplate.vstemplate文件,你需要重新把在该文件夹中的所有内容压缩回LibraryApp Starter Kit.zip文件中去。你可以全选在这个文件夹下的文件,右击并选择"Send To"-"Compressed(zipped) Folder"(见图11)。 498)this.style.width=498;" border=0> 图11.Zipper:把所有的文件压缩成一个文件以便于发行。
498)this.style.width=498;" border=0> 图12.改名:重命名你的.zip文件并且给它一个.vsi文件扩展名。
一个包含在该文件夹中所有的文件的.zip文件将出现在窗口的底部。重命名这个.zip文件为LibraryApp Starter Kit.zip并且把它移动到你的在一个称为\Visual Studio 2005\My Exported Templates\的文件夹下的My Documents 部分。 6. 使用Visual Studio Installer打包Starter Kit 现在既然这个模板被创建成功并得到修改,那么你还需要一步来把它打包成一个Starter Kit。在你刚才创建的文件夹中,创建一新文件并把它保存为LibraryApp.vscontent。然后,用下面方式填充这个LibraryApp.vscontent文件: <VSContent xmlns="http://schemas.microsoft.com/developer/vscontent/2005"> <Content> <FileName>LibraryApp Starter Kit.zip</FileName> <DisplayName>Library Application Starter Kit</DisplayName> <Description>VSTemplate for VB project</Description> <FileContentType>VSTemplate</FileContentType> <ContentVersion>1.0</ContentVersion> <Attributes> <Attribute name="TemplateType" value="Project"></Attribute> <Attribute name="ProjectType" value="Visual Basic"></Attribute> <Attribute name="ProjectSubType" value=""></Attribute> </Attributes> </Content> </VSContent> |
在相同的文件夹中,创建一个新的空.zip文件(File-->New-->Compressed(zipped)文件夹)。拖放这个LibraryApp Starter Kit.zip和LibraryApp.vscontent文件到最新创建的.zip文件。最后,重命名该.zip文件LibraryApp Starter Kit.vsi(见图12)。 就是这么简单!这个.vsi文件现在就成了一个Starter Kit。 7. 安装Starter Kit 一旦创建完Starter Kit,你就可以把它发布给你的同伴开发者。一个不错的分发方法是把它放到网上去让他们下载。 为了安装这个Starter Kit,简单地双击该.vsi文件,则这个安装器就会显示在如图13所示的对话框中。点击Next继续下去。你将得到有关你要安装内容的安全警告信息。点击Yes继续下去。在最后的对话框中,点击Finish并关闭。 498)this.style.width=498;" border=0> 图13.安装:这个对话框将允许你选择要从.vsi中安装的内容。
498)this.style.width=498;" border=0> 图14.My Template:你的新Starter Kit,包括文档,应该位于Visual Studio 的My Templates部分。
为了校验这个Starter Kit被正确安装,启动Visual Studio 2005并且创建一新工程(File-->New-->Project)。你会看到LibraryApp Starter Kit模板位于My Templates部分(见图14)。选择这个模板并且点按OK。之后,你就会发现文档文件被自动加载。 你可以按下F5键来验证该应用程序如下面所述的那样工作(记住要使用你自己的Amazon订阅ID)。现在,你可以继续增强这个程序以适合你自己的需要。 在本文中,你学到了创建一个Starter Kit的详细过程。Starter Kit是学习编程的一种好方法,也是学习业界专家解决实际问题的最好跳板。
<<上一页
1
2
|