Wix制作安装包


<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="*" Name="Nuotu" Language="2052" Version="1.0.0.0"
           Manufacturer="Microsoft" UpgradeCode="22cc56cc-63e3-40ce-bd91-4763f7473f6c"
    Codepage="936"  >
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes" />

    <!--net2.0 NETFRAMEWORK20;net3.0 NETFRAMEWORK30 net3.5 NETFRAMEWORK35 net4.0 NETFRAMEWORK40FULL net4.5 NETFRAMEWORK45-->
    <PropertyRef Id="NETFRAMEWORK20" />
    <Condition Message='安装需要Microsoft .NET Framework 2.0,请先安装(dotnetfx20_full_x86_x64.exe)'>
      <![CDATA[Installed OR NETFRAMEWORK20]]>
    </Condition>

   

    <UI>
      <!--所选目录,DIR就是所选目录,名称唯一就行,但是必须大写,否则还是安装在c盘-->
      <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_FOLDER" />

      <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Welcome" />

      <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="完成后启动" />

      <Property Id="WixShellExecTarget" Value="[#NuotuClientRegisterExe]" />

      <!--UI引用-->
      <UIRef Id="WixUI_InstallDir" />
      <!--退出对话框-->
      <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">
        WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed
      </Publish>
    </UI>

    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

   <Feature Id="ProductFeature" Title="Nuotu" Level="1">
      <ComponentRef Id="INSTALL_FOLDER_Component" />
      <ComponentRef Id="INSTALL_FOLDER_Config_Component" />
      <ComponentRef Id="DesktopFolderShortcut" />
      <ComponentRef Id="RegistryEntry" />
      <!--添加组件引用-->
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
        
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <!--安装路径-->
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALL_FOLDER" Name="Nuotu" >
          <Directory Id="INSTALL_FOLDER_Config" Name="Config" />
        </Directory>
      </Directory>

      <!--开始菜单文件夹-->
      <!--
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ProgramMenuDir" Name="Nuoto" />
      </Directory>-->

      <!--桌面-->
      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>


    <!--程序目录配置-->
    <DirectoryRef Id="INSTALL_FOLDER">
      <Component Id="INSTALL_FOLDER_Component" Guid="5E254582-DD5F-423D-8333-843457282026">
        <File Id="NuotuClientExe" Source="NuotuClient.exe" />
        <File Id="NuotuClientRegisterExe" Source="NuotuClientRegister.exe" />
        <File Id="NewtonsoftJsonDll" Source="Newtonsoft.Json.dll" />
        <RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION" Name="NuotuClient.exe" Type="integer" Value="11001" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    
     <DirectoryRef Id="INSTALL_FOLDER_Config">
      <Component Id="INSTALL_FOLDER_Config_Component" Guid="5E254582-DD5F-423D-8333-843457282027">
        <File Id="URLTxt" Source="Config/URL.txt" />
        <File Id="ServiceURLTxt" Source="Config/ServiceURL.txt" />
        <File Id="PWTxt" Source="Config/PW.txt" />
      </Component>
    </DirectoryRef>

    <!--桌面快捷键-->
    <DirectoryRef Id="DesktopFolder">
      <Component Id="DesktopFolderShortcut" Guid="5A254682-1D1F-413D-8333-144457282026">
        <Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="MyWixDemo" Target="[DIR]NuotuClient.exe"  WorkingDirectory="DIR"
                  Icon="DesktopSeed32x32.ico">
          <Icon Id="DesktopSeed32x32.ico" SourceFile="DesktopSeed32x32.ico" />
        </Shortcut>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\NuotuClient" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>

    <!--修改注册表 -->
    <DirectoryRef Id="TARGETDIR">
      <Component Id="RegistryEntry" Guid="C26D6547-BB6B-49C3-9286-8DCDC1961B3D">
        <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION">
          <RegistryValue Type="integer" Name="NuotuClient.exe" Value="1" KeyPath="yes" />
        </RegistryKey>
      </Component>
    </DirectoryRef>

  </Fragment>

  <Fragment>

    <!--组件,默认所添加的组件在安装目录-->
    <ComponentGroup Id="ProductComponents" Directory="INSTALL_FOLDER">
      <Component Id='RemoveFiles' Guid='{F341A78A-44EA-40B7-BDFD-5CA09DF7EB3F}' KeyPath='yes'>
        <RemoveFolder Id="INSTALL_FOLDER"  On="uninstall" />
        <RemoveFolder Id="ProgramMenuDir"  On="uninstall" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

猜你喜欢

转载自zheyiw.iteye.com/blog/2314982