github.com/nuvolaris/nuv@v0.0.0-20240511174247-a74e3a52bfd8/bin/windows/templates/product.wxs (about) 1 <?xml version="1.0"?> 2 <!-- 3 ~ Licensed to the Apache Software Foundation (ASF) under one 4 ~ or more contributor license agreements. See the NOTICE file 5 ~ distributed with this work for additional information 6 ~ regarding copyright ownership. The ASF licenses this file 7 ~ to you under the Apache License, Version 2.0 (the 8 ~ "License"); you may not use this file except in compliance 9 ~ with the License. You may obtain a copy of the License at 10 ~ 11 ~ http://www.apache.org/licenses/LICENSE-2.0 12 ~ 13 ~ Unless required by applicable law or agreed to in writing, 14 ~ software distributed under the License is distributed on an 15 ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 ~ KIND, either express or implied. See the License for the 17 ~ specific language governing permissions and limitations 18 ~ under the License. 19 --> 20 <?if $(sys.BUILDARCH)="x86"?> 21 <?define Program_Files="ProgramFilesFolder"?> 22 <?elseif $(sys.BUILDARCH)="x64"?> 23 <?define Program_Files="ProgramFiles64Folder"?> 24 <?else?> 25 <?error Unsupported value of sys.BUILDARCH=$(sys.BUILDARCH)?> 26 <?endif?> 27 28 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 29 30 <Product Id="*" UpgradeCode="{{.UpgradeCode}}" 31 Name="{{.Product}}" 32 Version="{{.VersionOk}}" 33 Manufacturer="{{.Company}}" 34 Language="1033"> 35 36 <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" InstallScope="perMachine"/> 37 38 <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/> 39 40 <Upgrade Id="{{.UpgradeCode}}"> 41 <UpgradeVersion Minimum="{{.VersionOk}}" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/> 42 <UpgradeVersion Minimum="0.0.0" Maximum="{{.VersionOk}}" IncludeMinimum="yes" IncludeMaximum="no" 43 Property="OLDERVERSIONBEINGUPGRADED"/> 44 </Upgrade> 45 <Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition> 46 47 <Directory Id="TARGETDIR" Name="SourceDir"> 48 49 <Directory Id="$(var.Program_Files)"> 50 <Directory Id="INSTALLDIR" Name="{{.Product}}"> 51 {{if gt (.Files.Items | len) 0}} 52 <Component Id="ApplicationFiles" Guid="{{.Files.GUID}}"> 53 {{range $i, $e := .Files.Items}} 54 <File Id="ApplicationFile{{$i}}" Source="{{$e}}"/> 55 {{end}} 56 </Component> 57 {{end}} 58 {{if gt (.Directories | len) 0}} 59 {{range $i, $e := .Directories}} 60 <Directory Id="APPDIR{{$i}}" Name="{{$e}}" /> 61 {{end}} 62 {{end}} 63 </Directory> 64 </Directory> 65 66 {{if gt (.Env.Vars | len) 0}} 67 <Component Id="ENVS" Guid="{{.Env.GUID}}"> 68 {{range $i, $e := .Env.Vars}} 69 <Environment Id="ENV{{$i}}" 70 Name="{{$e.Name}}" 71 Value="{{$e.Value}}" 72 Permanent="{{$e.Permanent}}" 73 Part="{{$e.Part}}" 74 Action="{{$e.Action}}" 75 System="{{$e.System}}" /> 76 {{end}} 77 </Component> 78 {{end}} 79 80 {{if gt (.Shortcuts.Items | len) 0}} 81 <Directory Id="ProgramMenuFolder"> 82 <Directory Id="ProgramMenuSubfolder" Name="{{.Product}}"> 83 <Component Id="ApplicationShortcuts" Guid="{{.Shortcuts.GUID}}"> 84 {{range $i, $e := .Shortcuts.Items}} 85 <Shortcut Id="ApplicationShortcut{{$i}}" 86 Name="{{$e.Name}}" 87 Description="{{$e.Description}}" 88 Target="{{$e.Target}}" 89 WorkingDirectory="{{$e.WDir}}" 90 {{if gt ($e.Arguments | len) 0}} 91 Arguments="{{$e.Arguments}}" 92 {{end}} 93 > 94 {{if gt ($e.Icon | len) 0}} 95 <Icon Id="Icon{{$i}}" SourceFile="{{$e.Icon}}" /> 96 {{end}} 97 </Shortcut> 98 <RegistryValue Root="HKCU" 99 Key="Software\{{$.Company}}\{{$.Product}}" 100 Name="installed{{$i}}" 101 Type="integer" Value="1" KeyPath="yes"/> 102 {{end}} 103 <RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/> 104 </Component> 105 </Directory> 106 </Directory> 107 {{end}} 108 109 </Directory> 110 111 {{range $i, $e := .InstallHooks}} 112 <SetProperty Id="CustomInstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomInstallExec{{$i}}" Sequence="execute"/> 113 <CustomAction Id="CustomInstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/> 114 {{end}} 115 {{range $i, $e := .UninstallHooks}} 116 <SetProperty Id="CustomUninstallExec{{$i}}" Value="{{$e.CookedCommand}}" Before="CustomUninstallExec{{$i}}" Sequence="execute"/> 117 <CustomAction Id="CustomUninstallExec{{$i}}" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no"/> 118 {{end}} 119 <InstallExecuteSequence> 120 <RemoveExistingProducts After="InstallValidate"/> 121 {{range $i, $e := .InstallHooks}} 122 <Custom Action="CustomInstallExec{{$i}}" After="{{if eq $i 0}}InstallFiles{{else}}CustomInstallExec{{dec $i}}{{end}}">NOT Installed AND NOT REMOVE</Custom> 123 {{end}} 124 {{range $i, $e := .UninstallHooks}} 125 <Custom Action="CustomUninstallExec{{$i}}" After="{{if eq $i 0}}InstallInitialize{{else}}CustomUninstallExec{{dec $i}}{{end}}">REMOVE ~= "ALL"</Custom> 126 {{end}} 127 </InstallExecuteSequence> 128 129 <Feature Id="DefaultFeature" Level="1"> 130 {{if gt (.Env.Vars | len) 0}} 131 <ComponentRef Id="ENVS"/> 132 {{end}} 133 {{if gt (.Files.Items | len) 0}} 134 <ComponentRef Id="ApplicationFiles"/> 135 {{end}} 136 {{if gt (.Shortcuts.Items | len) 0}} 137 <ComponentRef Id="ApplicationShortcuts"/> 138 {{end}} 139 {{range $i, $e := .Directories}} 140 <ComponentGroupRef Id="AppFiles{{$i}}" /> 141 {{end}} 142 </Feature> 143 144 <UI> 145 <!-- Define the installer UI --> 146 <UIRef Id="WixUI_HK" /> 147 </UI> 148 149 <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> 150 151 <!-- this should help to propagate env var changes --> 152 <CustomActionRef Id="WixBroadcastEnvironmentChange" /> 153 154 </Product> 155 156 </Wix>