product.wxs (6846B)
1 <?xml version="1.0"?> 2 3 <?if $(sys.BUILDARCH)="x86"?> 4 <?define Program_Files="ProgramFilesFolder"?> 5 <?elseif $(sys.BUILDARCH)="x64"?> 6 <?define Program_Files="ProgramFiles64Folder"?> 7 <?else?> 8 <?error Unsupported value of sys.BUILDARCH=$(sys.BUILDARCH)?> 9 <?endif?> 10 11 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 12 13 <Product Id="*" UpgradeCode="{{.UpgradeCode}}" 14 Name="{{.Product}}" 15 Version="{{.VersionOk}}" 16 Manufacturer="{{.Company}}" 17 Language="1033"> 18 19 <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" InstallScope="perMachine"/> 20 21 <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/> 22 23 <Upgrade Id="{{.UpgradeCode}}"> 24 <UpgradeVersion Minimum="{{.VersionOk}}" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/> 25 <UpgradeVersion Minimum="0.0.0" Maximum="{{.VersionOk}}" IncludeMinimum="yes" IncludeMaximum="no" 26 Property="OLDERVERSIONBEINGUPGRADED"/> 27 </Upgrade> 28 <Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition> 29 30 <Directory Id="TARGETDIR" Name="SourceDir"> 31 32 <Directory Id="$(var.Program_Files)"> 33 <Directory Id="INSTALLDIR" Name="{{.Product}}"> 34 {{if gt (.Files.Items | len) 0}} 35 <Component Id="ApplicationFiles" Guid="{{.Files.GUID}}"> 36 {{range $i, $e := .Files.Items}} 37 <File Id="ApplicationFile{{$i}}" Source="{{$e}}"/> 38 {{end}} 39 </Component> 40 {{end}} 41 {{if gt (.Directories | len) 0}} 42 {{range $i, $e := .Directories}} 43 <Directory Id="APPDIR{{$i}}" Name="{{$e}}" /> 44 {{end}} 45 {{end}} 46 </Directory> 47 </Directory> 48 49 {{if gt (.Env.Vars | len) 0}} 50 <Component Id="ENVS" Guid="{{.Env.GUID}}"> 51 {{range $i, $e := .Env.Vars}} 52 <Environment Id="ENV{{$i}}" 53 Name="{{$e.Name}}" 54 Value="{{$e.Value}}" 55 Permanent="{{$e.Permanent}}" 56 Part="{{$e.Part}}" 57 Action="{{$e.Action}}" 58 System="{{$e.System}}" /> 59 {{end}} 60 </Component> 61 {{end}} 62 63 {{if gt (.Shortcuts.Items | len) 0}} 64 <Directory Id="ProgramMenuFolder"> 65 <Directory Id="ApplicationProgramsFolder" Name="{{.Product}}"> 66 <Component Id="ApplicationShortcut" Guid="6743f868-7229-4caa-9064-d05ee7fca371"> 67 {{range $i, $e := .Shortcuts.Items}} 68 <Shortcut Id="ApplicationStartMenuShortcut" 69 Name="{{$e.Name}}" 70 Description="{{$e.Description}}" 71 Target="{{$e.Target}}" 72 WorkingDirectory="{{$e.WDir}}" 73 > 74 <Icon Id="Icon{{$i}}_Menu" SourceFile="{{$e.Icon}}" /> 75 </Shortcut> 76 <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/> 77 <RegistryValue Root="HKCU" 78 Key="Software\{{$.Company}}\{{$.Product}}" 79 Name="installed{{$i}}" 80 Type="integer" Value="1" KeyPath="yes"/> 81 {{end}} 82 </Component> 83 </Directory> 84 <Directory Id="ProgramMenuSubfolder" Name="{{.Product}}"> 85 <Component Id="ApplicationShortcuts" Guid="{{.Shortcuts.GUID}}"> 86 {{range $i, $e := .Shortcuts.Items}} 87 <Shortcut Id="ApplicationShortcut{{$i}}" 88 Name="{{$e.Name}}" 89 Description="{{$e.Description}}" 90 Target="{{$e.Target}}" 91 WorkingDirectory="{{$e.WDir}}" 92 {{if gt ($e.Arguments | len) 0}} 93 Arguments="{{$e.Arguments}}" 94 {{end}} 95 > 96 {{if gt ($e.Icon | len) 0}} 97 <Icon Id="Icon{{$i}}" SourceFile="{{$e.Icon}}" /> 98 {{end}} 99 </Shortcut> 100 <RegistryValue Root="HKCU" 101 Key="Software\{{$.Company}}\{{$.Product}}" 102 Name="installed{{$i}}" 103 Type="integer" Value="1" KeyPath="yes"/> 104 {{end}} 105 <RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/> 106 </Component> 107 </Directory> 108 </Directory> 109 {{end}} 110 111 </Directory> 112 113 {{range $i, $e := .InstallHooks}} 114 <SetProperty Id="CustomInstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomInstallExec{{$i}}" Sequence="execute"/> 115 <CustomAction Id="CustomInstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/> 116 {{end}} 117 {{range $i, $e := .UninstallHooks}} 118 <SetProperty Id="CustomUninstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomUninstallExec{{$i}}" Sequence="execute"/> 119 <CustomAction Id="CustomUninstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/> 120 {{end}} 121 <InstallExecuteSequence> 122 <RemoveExistingProducts After="InstallValidate"/> 123 {{range $i, $e := .InstallHooks}} 124 <Custom Action="CustomInstallExec{{$i}}" After="{{if eq $i 0}}InstallFiles{{else}}CustomInstallExec{{dec $i}}{{end}}">NOT Installed AND NOT REMOVE</Custom> 125 {{end}} 126 {{range $i, $e := .UninstallHooks}} 127 <Custom Action="CustomUninstallExec{{$i}}" After="{{if eq $i 0}}InstallInitialize{{else}}CustomUninstallExec{{dec $i}}{{end}}">REMOVE ~= "ALL"</Custom> 128 {{end}} 129 </InstallExecuteSequence> 130 131 <Feature Id="DefaultFeature" Level="1"> 132 {{if gt (.Env.Vars | len) 0}} 133 <ComponentRef Id="ENVS"/> 134 {{end}} 135 {{if gt (.Files.Items | len) 0}} 136 <ComponentRef Id="ApplicationFiles"/> 137 {{end}} 138 {{if gt (.Shortcuts.Items | len) 0}} 139 <ComponentRef Id="ApplicationShortcuts"/> 140 {{end}} 141 {{range $i, $e := .Directories}} 142 <ComponentGroupRef Id="AppFiles{{$i}}" /> 143 {{end}} 144 <ComponentRef Id="ApplicationShortcut" /> 145 </Feature> 146 147 <UI> 148 <!-- Define the installer UI --> 149 <UIRef Id="WixUI_HK" /> 150 </UI> 151 152 <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> 153 154 <!-- this should help to propagate env var changes --> 155 <CustomActionRef Id="WixBroadcastEnvironmentChange" /> 156 157 </Product> 158 159 </Wix>