Welcome

首页 / 软件开发 / .NET编程技术 / Visual Studio DSL 入门14---用Wix制作安装程序

Visual Studio DSL 入门14---用Wix制作安装程序2011-04-21 博客园 似水流年我们到现在为止已经对Vs.net dsl的基础知识进行了介绍,并且一步一步的完成了我们的状态机设计器的设计,在上一节结合T4模板生成了代码.但是我们一直还是在调试的项目中来做的, 怎么能够让我们做的这个状态机设计器能够提供给其它人使用呢,在这一节,我们就来做一个安装程序,这样在只安装了VS.NET的机器上,不用安装SDK就可以使用我们的设计器了.

VS.NET DSL专门提供了针对DSL的安装项目,我们直接基于这个项目来制作我们的安装程序:

1.首先,向我们的解决方案中添加一个Dsl 安装项目,从项目类型中选择Extensibility—Domain Specific Language Setup:

2. 我们可以看到在生成的项目中, 还是由很多tt文件, 其实dsl的安装是基于开源项目wix,不过在一般情况下,我们不需要手动去修改wix文件,不过如果一旦有特殊的需求,现有的这种机制是很难满足的. 我们来介绍一下这种安装机制:

当我们向这个解决方案中添加DSL setup项目时,它会自动的寻找Dsl项目和DslPackage项目,并自动添加对这两个项目的引用,然后根据这两个项目中生成自己的元数据文件 InstallerDefinition.dslsetup,我们来看一下这个文件:

<installerDefinition xmlns="http://schemas.microsoft.com/VisualStudio/2005/DslTools/InstallerDefinitionModel" 

productUrl="InsertProductUrlHere"

defaultDirectoryName="LanguageSm"

productVersion="1.0.0"

requiresCSharp="true"

requiresVisualBasic="true"

productCode="326b807c-a6da-43ac-9d29-f75cf060622a"

upgradeCode="cc04b782-48c3-49c5-a60e-eda39258bfaa"

localeId="1033">

<dslPackage name="LanguageSm" project="DslPackage" assemblyPath="Company.LanguageSm.DslPackage.dll" registryRoot="SOFTWAREMicrosoftVisualStudio9.0">

<fileExtensions>

<fileExtension name="mydsl5" extension="mydsl5" descriptionKey="FileDescription" hasIcon="true" iconId="0"/>

</fileExtensions>

<supportingAssemblies>

<supportingAssembly name="Dsl" project="Dsl" assemblyPath="Company.LanguageSm.Dsl.dll"/>

</supportingAssemblies>

</dslPackage>

<licenseAgreement filePath="FilesEULA.rtf" isEmbedded="true" />

<supportingFiles>

<supportingFile name="Readme" filePath="FilesReadme.htm" installShortcut="true" shortcutIconPath="ResourcesReadmeShortcut.ico" openAfterInstall="true" />

</supportingFiles>

<vsItemTemplates>

<vsItemTemplate localeId="1033" targetDirectories="CSharp" project="DslPackage" templatePath="CSharp1033LanguageSm.zip"/>

<vsItemTemplate localeId="1033" targetDirectories="VisualBasic" project="DslPackage" templatePath="VisualBasic1033LanguageSm.zip"/>

</vsItemTemplates>

<dslSchemas>

<dslSchema project="Dsl" filePath="GeneratedCodeLanguageSmSchema.xsd"/>

</dslSchemas>

</installerDefinition>