• WIX安装图文并茂简易说明


    一、           环境配置

    1.      安装VS2012

    2.      安装WixToolSet。安装完成后,VS中会多增加Windows Installer XML的项目。

    二、           构建打包项目

    1.    新建项目

    打开VS,新建Windows Installer XML项目。

    2.    编写Produc.wxs文件

    打开Product.wxs文件,其代码介绍参见图1,具体代码请参见附录。


    图1.           

    3.    设置全局变量

    注意:

    l  Define ‘Debug’ preprocessor variable一定要勾选上。

    l  全局变量在product.wix文件中的调用为$(var.xxx)格式,其中xxx为Define preprocessor variable中的名字,如PRODUCT_NAME。

    l  该product.wix所用到的全局变量有如下这些:PRODUCT_NAME=TestApp;MANUFACTURER=ABC;SOURCE_FILE_DIR=../../Release;APPLICATION_NAME=TestApp.exe;ICON_NAME=App.ico

    4.    相关DLL的引用

    (1).   .NET FRAMEWORK校验需要引用WixNetFxExtension.dll,该DLL的路径在C:Program Files (x86)WiX Toolset v3.7inWixNetFxExtension.dll,具体的路径与实际的安装环境有关。如果未引用编译将会出错。

    (2).   安装界面需要引用WixUIExtension.dll,该DLL的路径在C:Program Files (x86)WiX Toolset v3.7in

    WixUIExtension.dll,具体的路径与实际的安装环境有关。如果未引用编译将会出错。

    5.    生成MSI安装包

    编译项目,生成MSI安装包。

    附Product.wxs代码

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="{B7AF3561-68CB-4FEF-8DE4-C011AA462F62}" Name="$(var.PRODUCT_NAME)" Language="1033" Version="1.1.1.1"
               Manufacturer="$(var.MANUFACTURER)" UpgradeCode="{780EEB5A-ED25-4E85-AF66-C9EE996B2948}">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <!--net2.0 NETFRAMEWORK20;net3.0 NETFRAMEWORK30 net3.5 NETFRAMEWORK35 net4.0 NETFRAMEWORK40FULL net4.5 NETFRAMEWORK45-->
        <PropertyRef Id="NETFRAMEWORK40FULL"></PropertyRef>
        <Condition Message="This application requires .NET Framework 4.0. 
                   Please install the .NET Framework then run this installer again.">
          <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
        </Condition>
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes"/>
    
        <Feature Id="ProductFeature" Title="RandomCodePrintSetup" Level="1">
          <ComponentGroupRef Id="ProductComponents" />
        </Feature>
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_FOLDER"/>
        <UIRef Id="WixUI_InstallDir"/>
        <Icon Id="$(var.ICON_NAME)" SourceFile="$(var.SOURCE_FILE_DIR)/$(var.ICON_NAME)" />
      </Product>
    
      <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALL_MANUFACTURER" Name="$(var.MANUFACTURER)" >
              <Directory Id="INSTALL_FOLDER" Name="$(var.PRODUCT_NAME)" />
            </Directory>
          </Directory>
          <Directory Id="ProgramMenuFolder">
            <Directory Id="ProgramMenuDir" Name="$(var.PRODUCT_NAME)"></Directory>
          </Directory>
          <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
      </Fragment>
    
      <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALL_FOLDER">
          <Component Guid="{FDF4B1C0-E145-4B5B-BD80-B22958C84D6B}" Id="MainApplication">
            <File Id="MainApplication" Source="$(var.SOURCE_FILE_DIR)$(var.APPLICATION_NAME)" DiskId='1' KeyPath='yes'>
            </File>
          </Component>
          <Component Guid="{3E004D4A-7F18-4680-97E8-5B38860208AC}" Id="OtherFile">
            <File Id="Config" Source="$(var.SOURCE_FILE_DIR)Config.dll"></File>
            <File Id="TraceLog" Source="$(var.SOURCE_FILE_DIR) TraceLog.log"></File>
          </Component>
          <Component Id="ApplicationShortcut" Guid="{AEFEB53D-37C4-47CD-B7F5-0BF20C08F7B0}">
            <Shortcut Id="StartMenuShortcut"
                              Name="$(var.PRODUCT_NAME)"
                              Directory="ProgramMenuDir"
                              Target="[INSTALL_FOLDER]$(var.APPLICATION_NAME)"
                              WorkingDirectory="INSTALL_FOLDER"
                              Icon="$(var.ICON_NAME)" IconIndex="0"
                            />
            <Shortcut Id="DesktopShortcut"
                              Name="$(var.PRODUCT_NAME)"
                              Directory="DesktopFolder"
                              Target="[INSTALL_FOLDER]$(var.APPLICATION_NAME)"
                              WorkingDirectory="INSTALL_FOLDER"
                              Icon="$(var.ICON_NAME)" IconIndex="0"
                            />
            <Shortcut Id="UninstallStartMenu"
                              Name="Uninstall"
                              Directory="ProgramMenuDir"
                              Target="[SystemFolder]msiexec.exe"
                              Arguments="/x [ProductCode]"
                              Description="Uninstall"/>
            <Shortcut Id="UninstallINSTALL_FOLDER"
                              Name="Uninstall"
                              Directory="INSTALL_FOLDER"
                              Target="[SystemFolder]msiexec.exe"
                              Arguments="/x [ProductCode]"
                              Description="Uninstall"/>
            <RemoveFolder Id="RemoveShortcutFolder"  Directory="ProgramMenuDir" On="uninstall" />
            <RegistryKey Root="HKCU" Key="SoftwareMicrosoft[Manufacturer][ProductName]">
              <RegistryValue Name="StartMenuShortcut" Type="integer"  Value="1" KeyPath="yes" />
              <RegistryValue Name='Uninstall' Type='string'  Value='Uninstall'/>
            </RegistryKey>
          </Component>
          <Component Id='RemoveFiles' Guid='{F341A78A-44EA-40B7-BDFD-5CA09DF7EB3F}' KeyPath='yes'>
            <RemoveFolder Id="INSTALL_FOLDER" Directory="ProgramMenuFolder" On="uninstall" />
            <RemoveFolder Id="INSTALL_MANUFACTURER" Directory="ProgramMenuFolder" On="uninstall" />
            <RemoveFolder Id="ProgramMenuDir" Directory="ProgramMenuFolder" On="uninstall" />
          </Component>
        </ComponentGroup>
      </Fragment>
    </Wix>
    
    

  • 相关阅读:
    [Canvas学习]变形
    [Canvas学习]样式与颜色
    [Canvas学习]绘制图形
    上海 day31--线程
    上海 day31--进程间通信IPC机制、生产者与消费者模型
    关于 序列化模块 json 的小问题和小理解!!!
    上海 day30--并发编程、进程
    上海 day29-- UDP协议通信和socketserver模块
    上海 day28--套接字socket
    易用常用的小知识点
  • 原文地址:https://www.cnblogs.com/sparkleDai/p/7605075.html
Copyright © 2020-2023  润新知