Skip to content

Commit 77e98af

Browse files
committed
Ensure bundles are always x86
1 parent e86002d commit 77e98af

File tree

6 files changed

+31
-18
lines changed

6 files changed

+31
-18
lines changed

src/Layout/pkg/windows/Directory.Build.props

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
44

55
<PropertyGroup>
6-
<!-- Currently, WiX only supports 'full' for the -pdbType option and affects both bundle and package projects. -->
6+
<!-- Currently, WiX only supports 'full' for the -pdbType option. This affects both bundle and package projects. -->
77
<DebugType>full</DebugType>
8-
<Platform>$(TargetArchitecture)</Platform>
9-
<PlatformName>$(TargetArchitecture)</PlatformName>
10-
<InstallerPlatform>$(TargetArchitecture)</InstallerPlatform>
8+
9+
<!-- .wixproj defaults to AnyCPU which eventually defaults to x86. InstallerPlatform determines the bitness of
10+
the installer and should always match for MSIs. For bundles, we have to remain on x86. -->
11+
<InstallerPlatform Condition="'$(InstallerPlatform)' == ''">$(TargetArchitecture)</InstallerPlatform>
12+
<Platform>$(InstallerPlatform)</Platform>
13+
<PlatformName>$(InstallerPlatform)</PlatformName>
1114
</PropertyGroup>
1215

1316
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.wixproj'">
@@ -16,6 +19,7 @@
1619
<DefineConstants>$(DefineConstants);Manufacturer=Microsoft Corporation</DefineConstants>
1720
<DefineConstants>$(DefineConstants);MajorVersion=$(VersionMajor)</DefineConstants>
1821
<DefineConstants>$(DefineConstants);MinorVersion=$(VersionMinor)</DefineConstants>
22+
<DefineConstants>$(DefineConstants);TargetArchitecture=$(TargetArchitecture)</DefineConstants>
1923

2024
<!-- Technically we don't support .NET on any version of Windows where the version of Windows Installer is less than 5.0. -->
2125
<DefineConstants Condition="'$(InstallerPlatform)' != 'arm64'">$(DefineConstants);InstallerVersion=200</DefineConstants>

src/Layout/pkg/windows/Directory.Build.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!-- Example: Microsoft .NET SDK 10.0.100 -->
77
<DefineConstants>$(DefineConstants);SdkBrandName=$(SdkBrandName)</DefineConstants>
88
<!-- Example: Microsoft .NET SDK 10.0.100 (x64) -->
9-
<DefineConstants>$(DefineConstants);SdkPlatformBrandName=$(SdkBrandName) ($(InstallerPlatform))</DefineConstants>
9+
<DefineConstants>$(DefineConstants);SdkPlatformBrandName=$(SdkBrandName) ($(TargetArchitecture))</DefineConstants>
1010

1111
<!-- NativeMachine values match the expected values for image file machine constants
1212
https://docs.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants -->
@@ -39,4 +39,11 @@
3939
<!-- This target does nothing. It's intended to allow ProjectReference items to specify a target that has
4040
no build impact, but allow projects to participate in restore operations. -->
4141
<Target Name="Idle" />
42+
43+
<!-- This target is intended to catch changes that require someone to investigate. -->
44+
<Target Name="ValidateBuild" BeforeTargets="CoreCompile">
45+
<!-- Bundles must target x86 for back compat. -->
46+
<Error Condition="'$(OutputType)' == 'Bundle' AND '$(InstallerPlatform)' != 'x86'"
47+
Text="Bundles must target x86. InstallerPlatform=$(InstallerPlatform)" />
48+
</Target>
4249
</Project>

src/Layout/pkg/windows/bundles/sdk/bundle.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<Target Name="SetInstallerInfo" BeforeTargets="CoreCompile">
3434
<PropertyGroup>
3535
<!-- Product and version related preprocessor definitions. -->
36-
<DefineConstants>$(DefineConstants);ProductName=$(SdkBrandName) ($(InstallerPlatform))</DefineConstants>
36+
<DefineConstants>$(DefineConstants);ProductName=$(SdkBrandName) ($(TargetArchitecture))</DefineConstants>
3737
<DefineConstants>$(DefineConstants);WinFormsAndWpfVersion=$(WinFormsAndWpfVersion)</DefineConstants>
3838
<DefineConstants>$(DefineConstants);DotNetRuntimeVersion=$(DotNetRuntimeVersion)</DefineConstants>
3939
<DefineConstants>$(DefineConstants);AspNetCoreVersion=$(AspNetCoreVersion)</DefineConstants>

src/Layout/pkg/windows/bundles/sdk/bundle.wxs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@
3535
<util:RegistrySearchRef Id="RemoveSpecificPreviousVersionRegistryKeySearch"/>
3636

3737
<!-- MSI installers always write search keys to the 32-bit hive. -->
38-
<util:RegistrySearch Bitness="always32"
39-
Id="CheckDotnetInstallLocation_x86"
38+
<util:RegistrySearch Id="CheckDotnetInstallLocation_x86"
4039
Key="SOFTWARE\dotnet\Setup\InstalledVersions\x86"
4140
Result="exists"
4241
Root="HKLM"
4342
Value="InstallLocation"
4443
Variable="DotnetInstallLocationExists_x86" />
4544

4645
<util:RegistrySearch After="CheckDotnetInstallLocation_x86"
47-
Bitness="always32"
4846
Condition="DotnetInstallLocationExists_x86"
4947
Id="DotnetInstallLocation_x86"
5048
Variable="DOTNETHOME_X86"
@@ -54,18 +52,18 @@
5452
Value="InstallLocation" />
5553

5654
<util:FileSearch Id="DotnetExeSearch_x86"
57-
After="DotnetInstallLocation_x86"
58-
Variable="DotnetExeExists_x86"
59-
Condition="NOT DotnetInstallLocationExists_x86"
60-
Result="exists"
61-
Path="[ProgramFilesFolder]dotnet\dotnet.exe"/>
55+
After="DotnetInstallLocation_x86"
56+
Variable="DotnetExeExists_x86"
57+
Condition="NOT DotnetInstallLocationExists_x86"
58+
Result="exists"
59+
Path="[ProgramFilesFolder]dotnet\dotnet.exe"/>
6260
<util:DirectorySearch Id="DotnetExeLocation_x86"
6361
After="DotnetExeSearch_x86"
6462
Condition="DotnetExeExists_x86"
6563
Variable="DOTNETHOME_X86"
6664
Path="[ProgramFilesFolder]dotnet"/>
6765

68-
<?if $(InstallerPlatform)!=x86?>
66+
<?if $(TargetArchitecture)!=x86?>
6967
<util:RegistrySearch Id="CheckDotnetInstallLocation_x64"
7068
Variable="DotnetInstallLocationExists_x64"
7169
Result="exists"
@@ -107,7 +105,7 @@
107105
Variable="DOTNETHOME_X64"
108106
Path="[ProgramFiles64Folder]dotnet\x64"/>
109107
<?endif?>
110-
<?if $(InstallerPlatform)=arm64?>
108+
<?if $(TargetArchitecture)=arm64?>
111109
<util:RegistrySearch Id="CheckDotnetInstallLocation_arm64"
112110
Variable="DotnetInstallLocationExists_arm64"
113111
Result="exists"
@@ -185,7 +183,7 @@
185183
DetectCondition="WixBundleInstalled"
186184
Id="Finalizer"
187185
InstallCondition="WixBundleAction >= 4"
188-
UninstallArguments="&quot;[WixBundleLog_Finalizer]&quot; $(Version) $(Platform)"
186+
UninstallArguments="&quot;[WixBundleLog_Finalizer]&quot; $(Version) $(TargetArchitecture)"
189187
Vital="no" />
190188

191189
<!-- .NET Runtime has to be installed before the CLI because of a custom action that depends on dotnet.exe. -->

src/Layout/pkg/windows/msis/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.wixproj'">
55
<!-- This will only be passed through if project require harvesting files -->
66
<DefineConstants Condition="'$(DotnetSrc)' != ''">$(DefineConstants);DotnetSrc=$(DotnetSrc)</DefineConstants>
7-
</PropertyGroup>
7+
</PropertyGroup>
88

99
<!-- The WiX SDK sets TargetPath based on the OutputName or defaults to the project name. If the compiler detects any .wxl files, the specified culture
1010
values are included as a subdirectory (e.g. en-us) in the final output. When the output depends on computed properties that set during the build, the

src/Layout/redist/targets/GenerateMSIs.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,12 @@
291291
WriteOnlyWhenDifferent="true"
292292
Overwrite="true" />
293293

294+
<!-- The InstallerPlatform for bundles should always be x86. Changing this risks breaking existing code
295+
used to detect .NET installations and will impacting authoring for Microsoft Update. -->
294296
<MSBuild Projects="$(RepoRoot)src\Layout\pkg\windows\bundles\sdk\bundle.wixproj"
295297
Properties="UpgradeCode=$(UpgradeCode);BundleVersion=$(BundleVersion);
298+
TargetArchitecture=$(TargetArchitecture);
299+
InstallerPlatform=x86;
296300
InstallerPath=$(SdkBundleFile);
297301
OutputPath=$([System.IO.Path]::GetDirectoryName($(SdkBundleFile)));
298302
OutputName=$([System.IO.Path]::GetFileNameWithoutExtension($(SdkBundleFile)));

0 commit comments

Comments
 (0)