Quick Run an Installer with WiX

准备工作:
工具1) VS 2008 (非Express版) [Wix的Votive需要,最好打上SP1,VS 2005也支持]

2) WiX toolset (最新稳定版为 3.0.5419.0,我们这里所讲的都是基于3.0的特性) http://sourceforge.net/projects/wix/files/

 

开始:

工程1) 新建 工程,例如 C# WindowsFormsApplication (略...)

2) 安装Wix Toolset后,可以再VS中直接添加WiX工程,例如 WixProject

这里我们选择"添加新工程"

 

 

代码

1) WindowsFormsApplication (我这里选择什么都不做...)

2) WixProject (模板自动生成的代码,我们只需做小小修改:这里我们把WindowsFormsApplication的可执行文件作为源添加到Wix工程中)

WixProject
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    
<Product Id="e6ecf2a7-b03c-4b3f-ace8-6179ab62e4c7" Name="WixProject" Language="1033" Version="1.0.0.0" Manufacturer="WixProject" UpgradeCode="b3d503b8-4f21-4116-8562-6ff1e0e16a28">
        
<Package InstallerVersion="200" Compressed="yes" />

        
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

        
<Directory Id="TARGETDIR" Name="SourceDir">
            
<Directory Id="ProgramFilesFolder">
                
<Directory Id="INSTALLLOCATION" Name="WixProject">
                    
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
                     
<Component Id="ProductComponent" Guid="266b1212-45bf-4b65-a31a-29c3bdc43e20">
                         
<File Id="WindowsFormsApplication" Source="$(var.SolutionDir)\WindowsFormsApplication\$(var.OutDir)\WindowsFormsApplication.exe" />
                     
</Component> 
                
</Directory>
            
</Directory>
        
</Directory>

        
<Feature Id="ProductFeature" Title="WixProject" Level="1">
            
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
             
<ComponentRef Id="ProductComponent" /> 
        
</Feature>
    
</Product>
</Wix>

 

编译1) 编译(Release/Debug)整个工程
默认的Build Order,可以看的出Wix工程默认是最后一个被编译的,和Setup Project类似.

2) 修改Build error如果有的话

WiX的任何build error都会在Error List里显示出来,方便我们Fix

安装1) 双击$(SolutionDir)\WixProject\$(OutDir)\WixProject.msi

WixProject.wixpdb是包含相应的debugging信息,我们只需要关注WixProject.msi

双击后,基本上一闪而过,默认的UI~

2) 查看C:\Program Files\WixProject\

 

结束:

运行1) 运行WindowsFormsApplication.exe

2) 运行Run->appwiz.cpl->卸载或者右键WixProject.msi->卸载

总结1) 太简单啦,程序和安装都很简单,哈哈!

2) 安装居然只是简单的UI,除了title,看不到其他信息...

3) 用户不能自定义安装目录或者不能选择安装哪些组件

4) 还得在其他环境下做些测试才行!

5) 还有很多值得改善的地方,我们以后会慢慢的,一步一步的去做!敬请留意~ 

posted @ 2009-12-19 16:29  shalahu  阅读(1019)  评论(0编辑  收藏  举报