Skip to content

Commit f4e0deb

Browse files
committed
WiX: adjust the environment handling to handle dual purpose
Ensure that we properly handle the environment when installing. When performing a per-user install, we should modify the user's environment variables and when performing a per-machine install, modify the system environment variables.
1 parent 2539258 commit f4e0deb

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

platforms/Windows/bld.wxs

+9-4
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,14 @@
353353
</Component>
354354
</ComponentGroup>
355355

356-
<Component Id="EnvironmentVariables" Directory="INSTALLDIR" Guid="d01ea5b8-0f8a-4388-9b61-1186efddfc39">
357-
<Environment Id="Path" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Toolchains\$(var.ProductVersion)+Asserts\usr\bin" />
358-
</Component>
356+
<ComponentGroup Id="EnvironmentVariables">
357+
<Component Id="SystemEnvironmentVariables" Condition="MSIINSTALLPERUSER=0" Directory="INSTALLDIR" Guid="d01ea5b8-0f8a-4388-9b61-1186efddfc39">
358+
<Environment Id="SystemPath" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Toolchains\$(var.ProductVersion)+Asserts\usr\bin" />
359+
</Component>
360+
<Component Id="UserEnvironmentVariables" Condition="MSIINSTALLPERUSER=1" Directory="INSTALLDIR" Guid="ab52b870-23ee-42e8-9581-3fcbdfb9228c">
361+
<Environment Id="UserPath" Action="set" Name="Path" Part="last" Permanent="no" System="no" Value="[INSTALLDIR]Toolchains\$(var.ProductVersion)+Asserts\usr\bin" />
362+
</Component>
363+
</ComponentGroup>
359364

360365
<Feature Id="BuildTools" AllowAbsent="no" AllowAdvertise="yes" ConfigurableDirectory="INSTALLDIR" Description="Swift Build Tools" Level="1" Title="Swift Build Tools">
361366
<ComponentGroupRef Id="binutils" />
@@ -371,7 +376,7 @@
371376

372377
<ComponentGroupRef Id="ClangResources" />
373378

374-
<ComponentRef Id="EnvironmentVariables" />
379+
<ComponentGroupRef Id="EnvironmentVariables" />
375380
</Feature>
376381

377382
<UI>

platforms/Windows/runtime.wxs

+9-4
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@
9999
</Component>
100100
</ComponentGroup>
101101

102-
<Component Directory="INSTALLDIR" Id="EnvironmentVariables" Guid="8681d813-eb32-46f9-8b1c-f622b38b5eaf">
103-
<Environment Id="Path" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Runtimes\$(var.ProductVersion)\usr\bin" />
104-
</Component>
102+
<ComponentGroup Id="EnvironmentVariables">
103+
<Component Id="SystemEnvironmentVariables" Condition="MSIINSTALLPERUSER=0" Directory="INSTALLDIR" Guid="8681d813-eb32-46f9-8b1c-f622b38b5eaf">
104+
<Environment Id="SystemPath" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Runtimes\$(var.ProductVersion)\usr\bin" />
105+
</Component>
106+
<Component Id="UserEnvironmentVariables" Condition="MSIINSTALLPERUSER=1" Directory="INSTALLDIR" Guid="b83f6521-8708-4e2d-afef-076d8cdd7528">
107+
<Environment Id="UserPath" Action="set" Name="Path" Part="last" Permanent="no" System="no" Value="[INSTALLDIR]Runtimes\$(var.ProductVersion)\usr\bin" />
108+
</Component>
109+
</ComponentGroup>
105110

106111
<!-- Feature -->
107112
<Feature Id="SwiftRuntime" AllowAbsent="no" AllowAdvertise="yes" ConfigurableDirectory="INSTALLDIR" Description="Swift Windows Runtime ($(var.ProcessorArchitecture))" Level="1" Title="Swift Windows Runtime ($(var.ProcessorArchitecture))">
@@ -110,7 +115,7 @@
110115
<ComponentGroupRef Id="libdispatch" />
111116
<ComponentGroupRef Id="Foundation" />
112117

113-
<ComponentRef Id="EnvironmentVariables" />
118+
<ComponentGroupRef Id="EnvironmentVariables" />
114119
</Feature>
115120

116121
<Feature Id="SwiftUtilities" AllowAbsent="yes" AllowAdvertise="yes" Description="Extra Swift Utilities Windows ($(var.ProcessorArchitecture))" Level="1" Title="Swift Utilities Windows ($(var.ProcessorArchitecture))">

platforms/Windows/sdk.wxs

+11-5
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,16 @@
471471
</Component>
472472
</ComponentGroup>
473473

474-
<Component Directory="INSTALLDIR" Id="EnvironmentVariables" Guid="bd3ddc62-4c5c-4f6b-806e-02d2c6a65b65">
475-
<!-- <Condition> %PROCESSOR_ARCHITECTURE~="arm64" </Condition> -->
476-
<Environment Id="SDKRoot" Action="set" Name="SDKROOT" Part="all" Permanent="no" System="yes" Value="[INSTALLDIR]Platforms\Windows.platform\Developer\SDKs\Windows.sdk" />
477-
</Component>
474+
<ComponentGroup Id="EnvironmentVariables">
475+
<Component Id="SystemEnvironmentVariables" Condition="MSIINSTALLPERUSER=0" Directory="INSTALLDIR" Guid="bd3ddc62-4c5c-4f6b-806e-02d2c6a65b65">
476+
<!-- <Condition> %PROCESSOR_ARCHITECTURE~="arm64" </Condition> -->
477+
<Environment Id="SystemSDKRoot" Action="set" Name="SDKROOT" Part="all" Permanent="no" System="yes" Value="[INSTALLDIR]Platforms\Windows.platform\Developer\SDKs\Windows.sdk" />
478+
</Component>
479+
<Component Id="UserEnvironmentVariables" Condition="MSIINSTALLPERUSER=1" Directory="INSTALLDIR" Guid="580f1edd-8744-4be8-8dd8-e519f70a91e4">
480+
<!-- <Condition> %PROCESSOR_ARCHITECTURE~="arm64" </Condition> -->
481+
<Environment Id="UserSDKRoot" Action="set" Name="SDKROOT" Part="all" Permanent="no" System="no" Value="[INSTALLDIR]Platforms\Windows.platform\Developer\SDKs\Windows.sdk" />
482+
</Component>
483+
</ComponentGroup>
478484

479485
<!-- Features -->
480486
<Feature Id="SDK" AllowAbsent="no" AllowAdvertise="yes" ConfigurableDirectory="INSTALLDIR" Description="Swift Windows SDK ($(var.ProcessorArchitecture))" Level="1" Title="Swift Windows SDK ($(var.ProcessorArchitecture))">
@@ -502,7 +508,7 @@
502508

503509
<ComponentGroupRef Id="SwiftShims" />
504510

505-
<ComponentRef Id="EnvironmentVariables" />
511+
<ComponentGroupRef Id="EnvironmentVariables" />
506512
</Feature>
507513

508514
<UI>

0 commit comments

Comments
 (0)