|
8 | 8 | <Product Id="*" Name="rustup" Language="1033" Version="$(env.CFG_VER_MAJOR).$(env.CFG_VER_MINOR).$(env.CFG_VER_PATCH).0" Manufacturer="The Rust Project Developers" UpgradeCode="09acbb1c-7123-44ac-b2a9-4a04b28ced11">
|
9 | 9 | <Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" />
|
10 | 10 |
|
| 11 | + <Condition Message="The Rust toolchain is only supported on Windows 7, Windows Server 2008 R2, or higher."> |
| 12 | + <![CDATA[Installed OR (VersionNT >= 601)]]> |
| 13 | + </Condition> |
| 14 | + |
11 | 15 | <!-- TODO: How to configure updates? `AllowDowngrades` automatically removes previously installed versions, no matter what version they have -->
|
12 | 16 | <MajorUpgrade AllowDowngrades="yes" />
|
13 | 17 |
|
14 | 18 | <!-- Specifies a single cab file to be embedded in the installer's .msi. -->
|
15 | 19 | <MediaTemplate EmbedCab="yes" CompressionLevel="high" />
|
16 | 20 |
|
17 |
| - <Feature Id="ProductFeature" Title="rustup" Level="1"> |
18 |
| - <ComponentRef Id="CompleteInstallation" /> |
| 21 | + <Feature Id="Rustup" Title="rustup" Absent="disallow" Display="1" AllowAdvertise="no"> |
| 22 | + <ComponentRef Id="RustupExe" /> |
| 23 | + <ComponentRef Id="RegisterProductCode" /> |
| 24 | + <ComponentRef Id="RegisterInstallDir" /> |
| 25 | + </Feature> |
| 26 | + <!-- TODO: Add UI to actually let the user disable this Feature --> |
| 27 | + <Feature Id="Path" Title="Add to PATH" Absent="allow" Description="Add Rust to PATH environment variable" Display="2" AllowAdvertise="no"> |
| 28 | + <ComponentRef Id="ModifyPathEnv" /> |
19 | 29 | </Feature>
|
20 | 30 |
|
21 | 31 | <!-- Set some metadata that will appear in the "Installed Programs" list -->
|
|
35 | 45 | <UIRef Id="CustomUI" />
|
36 | 46 | <WixVariable Id="WixUIDialogBmp" Value="dialogbg.bmp" />
|
37 | 47 | <WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
|
38 |
| - <!-- TODO: Include/generate license file --> |
39 |
| - <!--<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />--> |
40 | 48 |
|
41 | 49 | <Directory Id="TARGETDIR" Name="SourceDir">
|
42 | 50 | <!-- `INSTALLLOCATION` will be set by custom action -->
|
|
46 | 54 | </Directory>
|
47 | 55 |
|
48 | 56 | <DirectoryRef Id="INSTALLLOCATION_BINARY">
|
49 |
| - <Component Id="CompleteInstallation" Guid="df2ab9f7-7888-465c-98dd-bb58cbca68f7"> |
| 57 | + <Component Id="RustupExe" Guid="df2ab9f7-7888-465c-98dd-bb58cbca68f7"> |
| 58 | + <!-- Install the main rustup.exe binary --> |
| 59 | + <File Source="$(var.RustupExe)" Name="rustup.exe" KeyPath="yes"/> |
| 60 | + </Component> |
| 61 | + <Component Id="RegisterInstallDir" Guid="*"> |
| 62 | + <!-- Remember the installation directory in the registry --> |
| 63 | + <RegistryKey Root="HKCU" Key="Software\rustup"> |
| 64 | + <RegistryValue Name="InstallDir" Type="string" Value="[INSTALLLOCATION]" KeyPath="yes"/> |
| 65 | + </RegistryKey> |
| 66 | + </Component> |
| 67 | + <Component Id="RegisterProductCode" Guid="*"> |
50 | 68 | <!-- Write the product code to the registry, so we can use it to run the uninstaller -->
|
51 | 69 | <RegistryKey Root="HKCU" Key="Software\rustup">
|
52 | 70 | <RegistryValue Name="InstalledProductCode" Type="string" Value="[ProductCode]" KeyPath="yes" />
|
53 | 71 | </RegistryKey>
|
54 |
| - <!-- Install the main rustup.exe binary --> |
55 |
| - <File Source="$(var.RustupExe)" Name="rustup.exe"/> |
56 |
| - <!-- Append to PATH environment variable --> |
57 |
| - <Environment Id="PATH" Name="PATH" Value="[INSTALLLOCATION_BINARY]" Permanent="no" Part="first" Action="set" System="no" /> |
| 72 | + </Component> |
| 73 | + <Component Id="ModifyPathEnv" Guid="*"> |
| 74 | + <!-- Prepend to PATH environment variable --> |
| 75 | + <RegistryValue Root="HKCU" Key="Software\rustup" Name="PathEnv" Type="string" Value="1" KeyPath="yes" /> |
| 76 | + <Environment Id="PathEnv" Name="PATH" Value="[INSTALLLOCATION_BINARY]" Permanent="no" Part="first" Action="set" System="no" /> |
58 | 77 | </Component>
|
59 | 78 | </DirectoryRef>
|
60 | 79 |
|
| 80 | + <!-- Read installation path from the registry. This is required for uninstall and upgrade |
| 81 | + and should only find something if rustup has already been installed via MSI. --> |
| 82 | + <Property Id="INSTALLLOCATION_REGISTRY"> |
| 83 | + <RegistrySearch Id="SearchRegistryInstallLocation" Root="HKCU" Key="Software\rustup" Name="InstallDir" Type="raw" /> |
| 84 | + </Property> |
| 85 | + |
| 86 | + <!-- Read environment variables `CARGO_HOME` and `RUSTUP_HOME`, because they won't be visible in custom actions later --> |
| 87 | + <SetProperty Action="ReadCargoHome" Id="CARGO_HOME" Value="[%CARGO_HOME]" Before="AppSearch" Sequence="first" /> |
| 88 | + <SetProperty Action="SetCargoHomeOverride" Id="CARGO_HOME_OR_DEFAULT" Value="[CARGO_HOME]" After="ReadCargoHome" Sequence="first">CARGO_HOME</SetProperty> |
| 89 | + <SetProperty Action="SetCargoHomeDefault" Id="CARGO_HOME_OR_DEFAULT" Value="[%USERPROFILE]\.cargo" After="ReadCargoHome" Sequence="first">NOT CARGO_HOME</SetProperty> |
| 90 | + |
| 91 | + <SetProperty Action="ReadRustupHome" Id="RUSTUP_HOME" Value="[%RUSTUP_HOME]" Before="AppSearch" Sequence="first" /> |
| 92 | + <SetProperty Action="SetRustupHomeOverride" Id="RUSTUP_HOME_OR_DEFAULT" Value="[RUSTUP_HOME]" After="ReadRustupHome" Sequence="first">RUSTUP_HOME</SetProperty> |
| 93 | + <SetProperty Action="SetRustupHomeDefault" Id="RUSTUP_HOME_OR_DEFAULT" Value="[%USERPROFILE]\.rustup" After="ReadRustupHome" Sequence="first">NOT RUSTUP_HOME</SetProperty> |
| 94 | + |
| 95 | + <!-- Looks for `rustup.exe` in `%USERPROFILE%\.cargo\bin` or `%CARGO_HOME%\bin` respectively --> |
| 96 | + <Property Id="RUSTUP_EXE_EXISTS"> |
| 97 | + <DirectorySearch Id="ExistingRustupExeSearch" Path="[CARGO_HOME_OR_DEFAULT]\bin" Depth="0"> |
| 98 | + <FileSearch Name="rustup.exe" /> |
| 99 | + </DirectorySearch> |
| 100 | + </Property> |
| 101 | + |
| 102 | + <!-- Looks for `%USERPROFILE%\.rustup` or `%RUSTUP_HOME%` respectively --> |
| 103 | + <Property Id="RUSTUP_DIRECTORY_EXISTS"> |
| 104 | + <DirectorySearch Id="ExistingRustupDirSearch" Path="[RUSTUP_HOME_OR_DEFAULT]" Depth="0" AssignToProperty="yes" /> |
| 105 | + </Property> |
| 106 | + |
| 107 | + <!-- This property will be set whenever a previous installation of rustup was found, even if it was not installed via MSI --> |
| 108 | + <SetProperty Id="RUSTUP_EXISTS" Value="1" After="AppSearch" Sequence="first">RUSTUP_EXE_EXISTS AND RUSTUP_DIRECTORY_EXISTS</SetProperty> |
| 109 | + |
| 110 | + <!-- Propagate correct value to INSTALLLOCATION directory --> |
| 111 | + <SetDirectory Action="AssignInstallLocationExisting" Id="INSTALLLOCATION" Value="[INSTALLLOCATION_REGISTRY]" Sequence="first">INSTALLLOCATION_REGISTRY</SetDirectory> |
| 112 | + <SetDirectory Action="AssignInstallLocationNew" Id="INSTALLLOCATION" Value="[CARGO_HOME_OR_DEFAULT]" Sequence="first">NOT INSTALLLOCATION_REGISTRY</SetDirectory> |
| 113 | + |
61 | 114 | <!-- Register the DLL containing the custom actions as an embedded binary -->
|
62 | 115 | <Binary Id="RustupCustomActionDll" SourceFile="$(var.RustupCustomActionDll)"/>
|
63 | 116 | <!-- Use a type 51 custom action to send options to deferred custom action `RustupInstall`
|
64 |
| - (can use arbitrary value that encodes all necessary properties and will be parsed from Rust) --> |
65 |
| - <CustomAction Id="SetInstallOptions" Property="RustupInstall" Value="... we can pass arbitrary options here ..." /> |
66 |
| - <CustomAction Id="RustupSetInstallLocation" BinaryKey="RustupCustomActionDll" DllEntry="RustupSetInstallLocation" Execute="immediate" Return="check" Impersonate="yes"/> |
67 |
| - <!-- Propagate the value of `RustupInstallLocation` (set by custom action) to `INSTALLLOCATION` --> |
68 |
| - <CustomAction Id="AssignInstallLocation" Directory="INSTALLLOCATION" Value="[RustupInstallLocation]"/> |
| 117 | + (can use arbitrary string that encodes all necessary properties and will be parsed from Rust) --> |
| 118 | + <CustomAction Id="SetInstallOptions" Property="RustupInstall" Value="INSTALLLOCATION=[INSTALLLOCATION];RUSTUP_HOME=[RUSTUP_HOME_OR_DEFAULT];RUSTUP_EXISTS=[RUSTUP_EXISTS]" /> |
| 119 | + <CustomAction Id="SetUninstallOptions" Property="RustupUninstall" Value="INSTALLLOCATION=[INSTALLLOCATION];RUSTUP_HOME=[RUSTUP_HOME_OR_DEFAULT];RUSTUP_EXISTS=[RUSTUP_EXISTS]" /> |
69 | 120 | <CustomAction Id="RustupInstall" BinaryKey="RustupCustomActionDll" DllEntry="RustupInstall" Execute="deferred" Return="check" Impersonate="yes"/>
|
70 | 121 | <CustomAction Id="RustupUninstall" BinaryKey="RustupCustomActionDll" DllEntry="RustupUninstall" Execute="deferred" Return="check" Impersonate="yes"/>
|
71 | 122 |
|
| 123 | + <!-- Schedule our custom actions --> |
72 | 124 | <InstallExecuteSequence>
|
73 |
| - <DisableRollback Before="InstallInitialize"/> |
74 |
| - <Custom Action="RustupSetInstallLocation" After="CostFinalize"/> |
75 |
| - <Custom Action="AssignInstallLocation" After="RustupSetInstallLocation"/> |
76 | 125 | <Custom Action="SetInstallOptions" Before="InstallInitialize">NOT Installed</Custom>
|
77 | 126 | <Custom Action="RustupInstall" After="InstallFiles">NOT Installed</Custom>
|
78 | 127 | <!-- Run RustupUninstall only on true uninstall, not on upgrade -->
|
| 128 | + <Custom Action="SetUninstallOptions" Before="InstallInitialize">Installed AND (NOT UPGRADINGPRODUCTCODE)</Custom> |
79 | 129 | <Custom Action="RustupUninstall" After="RemoveFiles">Installed AND (NOT UPGRADINGPRODUCTCODE)</Custom>
|
80 | 130 | </InstallExecuteSequence>
|
81 | 131 |
|
|
0 commit comments