Skip to content

Commit 40c1356

Browse files
authored
[WiX 5] Migrate SDK from v3 to v5 (#48699)
2 parents 35ad031 + 9843cb1 commit 40c1356

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1816
-2623
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ indent_brace_style = Allman
475475
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
476476
indent_size = 2
477477

478+
# WiX files
479+
[*.{wixproj,wxs,wxi,wxl,thm}]
480+
indent_size = 2
481+
478482
[*.{csproj,vbproj,proj,nativeproj,locproj}]
479483
charset = utf-8-bom
480484

Directory.Packages.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<PackageVersion Include="Microsoft.Web.Xdt" Version="$(MicrosoftWebXdtPackageVersion)" />
8080
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="$(MicrosoftWin32SystemEventsPackageVersion)" />
8181
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="$(MicrosoftWindowsCsWin32PackageVersion)" />
82+
<PackageVersion Include="Microsoft.WixToolset.Bal.wixext" Version="$(MicrosoftWixToolsetVersion)" />
83+
<PackageVersion Include="Microsoft.WixToolset.Dependency.wixext" Version="$(MicrosoftWixToolsetVersion)" />
84+
<PackageVersion Include="Microsoft.WixToolset.Heat" Version="$(MicrosoftWixToolsetVersion)" />
85+
<PackageVersion Include="Microsoft.WixToolset.Util.wixext" Version="$(MicrosoftWixToolsetVersion)" />
86+
<PackageVersion Include="Microsoft.WixToolset.UI.wixext" Version="$(MicrosoftWixToolsetVersion)" />
8287
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.386" />
8388
<PackageVersion Include="Moq" Version="$(MoqPackageVersion)" />
8489
<PackageVersion Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />

build.cmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
@echo off
22

3+
setlocal
4+
35
echo %* | findstr /C:"-pack" >nul
46
if %errorlevel%==0 (
5-
set SkipBuildingInstallers=
7+
set skipFlags="/p:SkipUsingCrossgen=false /p:SkipBuildingInstallers=false"
68
) else (
79
REM skip crossgen for inner-loop builds to save a ton of time
810
set skipFlags="/p:SkipUsingCrossgen=true /p:SkipBuildingInstallers=true"
911
)
1012
set DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT=true
1113
powershell -NoLogo -NoProfile -ExecutionPolicy ByPass -command "& """%~dp0eng\common\build.ps1""" -restore -build -msbuildEngine dotnet %skipFlags% %*"
14+
15+
endlocal
1216
exit /b %ErrorLevel%

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25373.106",
2525
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25373.106",
2626
"Microsoft.Build.NoTargets": "3.7.0",
27-
"Microsoft.Build.Traversal": "3.4.0"
27+
"Microsoft.Build.Traversal": "3.4.0",
28+
"Microsoft.WixToolset.Sdk": "5.0.2-dotnet.2737382"
2829
}
2930
}

src/Layout/finalizer/Program.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
using Microsoft.Win32;
66
using Microsoft.Win32.Msi;
77

8-
if (args.Length < 3)
8+
if (args.Length < 4)
99
{
1010
return (int)Error.INVALID_COMMAND_LINE;
1111
}
1212

1313
string logPath = args[0];
1414
string sdkVersion = args[1];
1515
string platform = args[2];
16+
int bundleAction = Convert.ToInt32(args[3]);
1617

1718
using StreamWriter logStream = new StreamWriter(logPath);
1819

@@ -21,8 +22,16 @@
2122
Logger.Log($"{nameof(logPath)}: {logPath}");
2223
Logger.Log($"{nameof(sdkVersion)}: {sdkVersion}");
2324
Logger.Log($"{nameof(platform)}: {platform}");
25+
Logger.Log($"{nameof(bundleAction)}: {bundleAction}");
2426
int exitCode = (int)Error.SUCCESS;
2527

28+
// The finalizer should only run when the parent bundle is being removed if WixBundleAction is set to BOOTSTRAPPER_ACTION_UNINSTALL
29+
// or BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL.
30+
if (bundleAction < 3 || bundleAction > 4)
31+
{
32+
return exitCode;
33+
}
34+
2635
try
2736
{
2837
// Step 1: Parse and format SDK feature band version

src/Layout/pkg/dotnet-sdk.proj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.Build.NoTargets">
1+
<Project Sdk="Microsoft.Build.NoTargets">
22

33
<PropertyGroup>
44
<BuildSdkRpm Condition="'$(BuildSdkRpm)' == '' and '$(IsRPMBasedDistro)' == 'true'">true</BuildSdkRpm>
@@ -33,6 +33,22 @@
3333

3434
<ItemGroup>
3535
<ProjectReference Include="..\redist\redist.csproj" ReferenceOutputAssembly="false" />
36+
</ItemGroup>
37+
38+
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
39+
<!-- These project references ensure that package references for WiX extensions are correctly restored. The Idle target is a no-op as the
40+
projects are built later when computed properties are available. These properties do not exist when projects are evaluated. -->
41+
<ProjectReference Include="windows\msis\placeholder\placeholder.wixproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true"
42+
Targets="Idle" />
43+
<ProjectReference Include="windows\msis\templates\templates.wixproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true"
44+
Targets="Idle" />
45+
<ProjectReference Include="windows\msis\toolset\toolset.wixproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true"
46+
Targets="Idle" />
47+
<ProjectReference Include="windows\bundles\sdk\bundle.wixproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true"
48+
Targets="Idle" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
3652
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Installers" />
3753
</ItemGroup>
3854

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
2+
<Project>
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
4+
5+
<PropertyGroup>
6+
<!-- Currently, WiX only supports 'full' for the -pdbType option. This affects both bundle and package projects. -->
7+
<DebugType>full</DebugType>
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>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.wixproj'">
17+
<DefineConstants>$(DefineConstants);SdkFeatureBandVersion=$(CliProductBandVersion)00</DefineConstants>
18+
<DefineConstants>$(DefineConstants);ProductLanguage=1033</DefineConstants>
19+
<DefineConstants>$(DefineConstants);Manufacturer=Microsoft Corporation</DefineConstants>
20+
<DefineConstants>$(DefineConstants);MajorVersion=$(VersionMajor)</DefineConstants>
21+
<DefineConstants>$(DefineConstants);MinorVersion=$(VersionMinor)</DefineConstants>
22+
<DefineConstants>$(DefineConstants);TargetArchitecture=$(TargetArchitecture)</DefineConstants>
23+
24+
<!-- Technically we don't support .NET on any version of Windows where the version of Windows Installer is less than 5.0. -->
25+
<DefineConstants Condition="'$(InstallerPlatform)' != 'arm64'">$(DefineConstants);InstallerVersion=200</DefineConstants>
26+
<DefineConstants Condition="'$(InstallerPlatform)' == 'arm64'">$(DefineConstants);InstallerVersion=500</DefineConstants>
27+
</PropertyGroup>
28+
</Project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
2+
<Project>
3+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
4+
5+
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.wixproj'">
6+
<!-- Example: Microsoft .NET SDK 10.0.100 -->
7+
<DefineConstants>$(DefineConstants);SdkBrandName=$(SdkBrandName)</DefineConstants>
8+
<!-- Example: Microsoft .NET SDK 10.0.100 (x64) -->
9+
<DefineConstants>$(DefineConstants);SdkPlatformBrandName=$(SdkBrandName) ($(TargetArchitecture))</DefineConstants>
10+
11+
<!-- NativeMachine values match the expected values for image file machine constants
12+
https://docs.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants -->
13+
<DefineConstants>$(DefineConstants);NativeMachine_x86=332</DefineConstants>
14+
<DefineConstants>$(DefineConstants);NativeMachine_x64=34404</DefineConstants>
15+
<DefineConstants>$(DefineConstants);NativeMachine_arm64=43620</DefineConstants>
16+
17+
<!-- This is the full semenatic version of the SDK. -->
18+
<DefineConstants>$(DefineConstants);Version=$(Version)</DefineConstants>
19+
<!-- BundleVersion is used by MSIs when generating provider keys, but ProductVersion is never used when generating bundles. -->
20+
<DefineConstants Condition="'$(ProductVersion)' != ''">$(DefineConstants);ProductVersion=$(ProductVersion)</DefineConstants>
21+
<DefineConstants Condition="'$(BundleVersion)' != ''">$(DefineConstants);BundleVersion=$(BundleVersion)</DefineConstants>
22+
</PropertyGroup>
23+
24+
<!-- MSI upgrade codes are generated based on the name of the installer, which typically includes the version and platform information. -->
25+
<Target Name="GenerateUpgradeCode" BeforeTargets="CoreCompile">
26+
<Error Condition="'$(InstallerPath)' == '' AND '$(UpgradeCode)' == ''"
27+
Text="Unable to compute UpgradeCode. The InstallerPath property is not set." />
28+
29+
<!-- Only use the file name when generating the GUID. Full paths may be inconsistent across different build environments. -->
30+
<GenerateGuidFromName Name="$([System.IO.Path]::GetFileName($(InstallerPath)))" Condition="'$(UpgradeCode)' == ''">
31+
<Output TaskParameter="GeneratedGuid" PropertyName="UpgradeCode" />
32+
</GenerateGuidFromName>
33+
34+
<PropertyGroup>
35+
<DefineConstants>$(DefineConstants);UpgradeCode=$(UpgradeCode)</DefineConstants>
36+
</PropertyGroup>
37+
</Target>
38+
39+
<!-- This target does nothing. It's intended to allow ProjectReference items to specify a target that has
40+
no build impact, but allow projects to participate in restore operations. -->
41+
<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>
49+
50+
<Target Name="GenerateWixpackPackage" AfterTargets="CoreCompile">
51+
<PropertyGroup>
52+
<WixpackWorkingDir>$(IntermediateOutputPath)wixpack</WixpackWorkingDir>
53+
<WixpackOutputDir>$(ArtifactsNonShippingPackagesDir)</WixpackOutputDir>
54+
</PropertyGroup>
55+
56+
<CreateWixBuildWixpack
57+
BindTrackingFile="$(IntermediateOutputPath)$(BindTrackingFilePrefix)%(CultureGroup.OutputSuffix)$(BindTrackingFileExtension)"
58+
Cultures="%(CultureGroup.Identity)"
59+
DefineConstants="$(DefineConstants);$(SolutionDefineConstants);$(ProjectDefineConstants);$(ProjectReferenceDefineConstants)"
60+
Extensions="@(_ResolvedWixExtensionPaths)"
61+
InstallerPlatform="$(InstallerPlatform)"
62+
InstallerFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetFileName)"
63+
IntermediateDirectory="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)"
64+
OutputFolder="$(WixpackOutputDir)"
65+
OutputType="$(OutputType)"
66+
PdbFile="$(IntermediateOutputPath)%(CultureGroup.OutputFolder)$(TargetPdbFileName)"
67+
PdbType="$(DebugType)"
68+
SourceFiles="@(Compile)"
69+
WixpackWorkingDir="$(WixpackWorkingDir)">
70+
<Output TaskParameter="OutputFile" PropertyName="_WixBuildCommandPackageNameOutput" />
71+
</CreateWixBuildWixpack>
72+
</Target>
73+
</Project>

src/Layout/pkg/windows/LCID/1028/bundle.wxl

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)