Skip to content

Commit 6454b4c

Browse files
authored
Conditionally set SYSTEM PATH in host install (#118092)
* Conditionally set SYSTEM PATH in host install * Address ICE18 error
1 parent b5f8e98 commit 6454b4c

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

src/installer/pkg/sfx/installers/dotnet-host.proj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
<!-- Contributes to DependencyKey which ensures stable provider key - do not change -->
1313
<WixDependencyKeyName>Dotnet_CLI_SharedHost</WixDependencyKeyName>
1414
<OutputFilesCandleVariable>HostSrc</OutputFilesCandleVariable>
15-
<MajorUpgradeSchedule>afterInstallExecute</MajorUpgradeSchedule>
15+
16+
<!-- Scheduling RemoveExistingProducts after InstallInitialize will remove the previous install first
17+
before installing the new version. This allows compositional changes in major upgrades
18+
and supports rollback, provided it is not turned off using machine policies (DisableRollback is not set to 1). -->
19+
<MajorUpgradeSchedule>afterInstallInitialize</MajorUpgradeSchedule>
1620
<VersionInstallerName>false</VersionInstallerName>
1721
<UseBrandingNameInLinuxPackageDescription>true</UseBrandingNameInLinuxPackageDescription>
1822
<MacOSComponentNamePackType>sharedhost</MacOSComponentNamePackType>
@@ -26,7 +30,7 @@
2630
<ItemGroup>
2731
<WixSrcFile Include="host.wxs" />
2832
<WixExtraComponentGroupRefId Include="InstallSharedHostandDetectionKeys" />
29-
<CandleVariables Include="ExtraPropertyRefIds" Value="ProductCPU;RTM_ProductVersion" />
33+
<CandleVariables Include="ExtraPropertyRefIds" Value="ProductCPU;RTM_ProductVersion;DISABLE_SETTING_HOST_PATH" />
3034
<!-- Enables stable provider key - do not change -->
3135
<CandleVariables Include="DependencyKey" Value="$(WixDependencyKeyName)_$(MajorVersion).$(MinorVersion)_$(TargetArchitecture)" />
3236
</ItemGroup>

src/installer/pkg/sfx/installers/host.wxs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,19 @@
3838
</RegistryKey>
3939
</Component>
4040

41-
<Component Id="cmdPath" Directory="DOTNETHOME" Guid="*">
41+
<Component Id="cmpPath" Directory="DOTNETHOME" Guid="*">
4242
<?if $(var.Platform)~=x64 ?>
43-
<!-- For x64 installer, only add to PATH when actually on native architecture -->
43+
<!-- For x64 installer, only add the sharedhost key when actually on native architecture. -->
4444
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
4545
<?elseif $(var.Platform)~=x86 ?>
46-
<!-- For x86 installer, only add to PATH when not on 64-bit platform -->
46+
<!-- For x86 installer, only add the key when not on 64-bit platform. -->
4747
<Condition>NOT VersionNT64</Condition>
4848
<?endif?>
4949

5050
<!-- A stable keypath with the right SxS characteristics for our PATH entry-->
5151
<RegistryKey Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost">
5252
<RegistryValue KeyPath="yes" Action="write" Name="Path" Type="string" Value="[DOTNETHOME]"/>
5353
</RegistryKey>
54-
<Environment Id="E_PATH" Name="PATH" Value="[DOTNETHOME]" Part="last" Action="set" System="yes" />
5554
</Component>
5655

5756
<Component Id="cmpLicenseFiles" Directory="DOTNETHOME" Guid="{A61CBE5B-1282-4F29-90AD-63597AA2372E}">
@@ -63,6 +62,7 @@
6362
</File>
6463
</Component>
6564

65+
<ComponentRef Id="cmpSetPath" />
6666
</ComponentGroup>
6767

6868
<Property Id="ProductCPU" Value="$(var.Platform)" />
@@ -76,6 +76,32 @@
7676
<CustomActionRef Id="Set_PROGRAMFILES_DOTNET_NON_NATIVE_ARCHITECTURE" />
7777
<?endif?>
7878
</Fragment>
79+
80+
<Fragment>
81+
<Property Id="DISABLE_SETTING_HOST_PATH" Secure="yes">
82+
<RegistrySearch Id="DisableSettingHostPathSearch" Root="HKLM" Key="SOFTWARE\Microsoft\.NET" Type="raw" Name="DisableSettingHostPath"/>
83+
</Property>
84+
85+
<Component Id="cmpSetPath" Guid="{0B910ED8-0877-473D-8658-647382324433}" Directory="DOTNETHOME">
86+
<CreateFolder />
87+
<!-- Always set the SYSTEM PATH, unless DisableSettingHostPath is 1. -->
88+
<?if $(var.Platform)~=x64 ?>
89+
<!-- For x64 installer, only add to PATH when actually on native architecture. -->
90+
<Condition><![CDATA[DISABLE_SETTING_HOST_PATH <> "#1" AND NOT NON_NATIVE_ARCHITECTURE]]></Condition>
91+
<?elseif $(var.Platform)~=x86 ?>
92+
<!-- For x86 installer, only add to PATH when not on 64-bit platform. -->
93+
<Condition><![CDATA[DISABLE_SETTING_HOST_PATH <> "#1" AND NOT VersionNT64]]></Condition>
94+
<?endif?>
95+
<Environment Id="E_PATH" Name="PATH" Value="[DOTNETHOME]" Part="last" Action="set" System="yes" />
96+
</Component>
97+
98+
<InstallExecuteSequence>
99+
<!-- Only broadcast the change if the component is enabled. -->
100+
<Custom Action="WixBroadcastEnvironmentChange" After="InstallFinalize">
101+
<![CDATA[DISABLE_SETTING_HOST_PATH <> "#1"]]>
102+
</Custom>
103+
</InstallExecuteSequence>
104+
</Fragment>
79105

80106
<Fragment>
81107
<!-- Unlike DOTNETHOME which gives precedence to a user specified value over an x64 suffix, here we always want the suffixed path -->

0 commit comments

Comments
 (0)