Skip to content

Commit 5c0dcde

Browse files
authored
Merge pull request #168 from spaghettidba/copilot/research-workloadtools-setup-projects
Migrate setup projects from WiX v3 to WiX v4 SDK-style
2 parents fecbe98 + 3809c9f commit 5c0dcde

File tree

14 files changed

+387
-369
lines changed

14 files changed

+387
-369
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"wix": {
6+
"version": "4.0.5",
7+
"commands": [
8+
"wix"
9+
]
10+
}
11+
}
12+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,4 @@ harvest3.wxs
266266
Setup/SignParams.ps1
267267
SetupBootstrapper/SignParams.ps1
268268
*.wixobj.nuget/nuget.exe
269-
*.wixobj
269+
*.wixobj

Setup/Product.wxs

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
33

44
<?if $(var.Platform) = x64 ?>
5-
<?define Win64 = "yes" ?>
65
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
7-
<?define PlatformReleaseFolder = "ReleaseX64" ?>
86
<?else ?>
9-
<?define Win64 = "no" ?>
107
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
11-
<?define PlatformReleaseFolder = "Release" ?>
128
<?endif ?>
139

1410
<?define ProductName="WorkloadTools" ?>
1511
<?define CompanyName="sqlconsulting.it" ?>
1612
<?define ProductVersion="$(var.BuildVersion)" ?>
17-
18-
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.CompanyName)" UpgradeCode="EF0F1905-E03F-4634-BB2E-3A5C3369AB23">
19-
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="$(var.Platform)" />
13+
14+
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)"
15+
Manufacturer="$(var.CompanyName)" UpgradeCode="EF0F1905-E03F-4634-BB2E-3A5C3369AB23">
16+
17+
<Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" />
2018

2119
<MajorUpgrade AllowDowngrades="yes" />
2220
<MediaTemplate EmbedCab="yes" />
2321

2422
<Property Id="REINSTALLMODE" Value="amus" />
2523

26-
2724
<!--
28-
These components are built using harvesting with Heat.
29-
The configuration is inside the .wixproj file,
30-
that contains a section named <Target Name="BeforeBuild">
31-
Inside that section there's a list of tags that control what Heat does.
32-
33-
Example:
34-
35-
<HeatDirectory OutputFile="$(ProjectDir)\harvest.wxs" Directory="..\SqlWorkload\bin\$(Platform)\$(Configuration)" ComponentGroupName="ProductComponents" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" PreprocessorVariable="var.SqlWorkload.TargetDir" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" NoLogo="true" Transforms="transform.xsl" />
36-
37-
Heat harvests all the files in the target folder of each project
38-
and builds a .wxs file that contains all the references to those file.
39-
If the same library is used by multiple projects, it will be present
40-
in multiple harvested .wxs files, which causes a "duplicate id" error
41-
during the build.
42-
For this reason, it is possible to exclude the libraries known to be
43-
duplicated, using the Transform attribute of the <HeatDirectory> tag.
44-
The transform is the path to a .xsl file that contains the transformations
45-
that you can apply to a .wxs file before using it.
46-
XSL is a complete sorcery to me, but the ones included in this projects
47-
contain the directives to remove known duplicate libraries.
25+
These component groups are generated by heat.exe in buildmsi.ps1.
26+
XSL transforms (transform.xsl, transform2.xsl, transform3.xsl) filter
27+
out duplicate and unwanted files across the component groups.
4828
-->
4929
<Feature Id="ProductFeature" Title="WorkloadTools" Level="1">
5030
<ComponentGroupRef Id="ProductComponents" />
5131
<ComponentGroupRef Id="WorkloadViewerComponents" />
5232
<ComponentGroupRef Id="ProductReports" />
53-
<ComponentGroupRef Id="ConvertWorkload" />
33+
<ComponentGroupRef Id="ConvertWorkloadComponents" />
5434
</Feature>
55-
35+
5636
</Product>
5737

5838
<Fragment>
@@ -77,14 +57,7 @@
7757
</Component>
7858
</ComponentGroup>
7959
</Fragment>
80-
<Fragment>
81-
<ComponentGroup Id="ConvertWorkload">
82-
<Component Id="ConvertWorkloadId" Directory="INSTALLFOLDER" Guid="633CDC2A-00D2-403D-BBD3-5E96A79AA5A8">
83-
<File Id="ConvertWorkloadExeId" Source="..\ConvertWorkload\bin\release\ConvertWorkload.exe" />
84-
</Component>
85-
</ComponentGroup>
86-
</Fragment>
87-
60+
8861
<Fragment>
8962
<ComponentGroup Id="ProductLicense">
9063
<Component Id="cmpE591726ED3774E44B75D7106236DD456" Directory="INSTALLFOLDER" Guid="2CA2DACC-347C-449E-A39E-4A68310BDAB1">

Setup/Setup.wixproj

Lines changed: 45 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,68 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
WiX v3 MSBuild project. Requires WiX Toolset v3.x to be installed.
4+
See https://wixtoolset.org/ to download WiX v3.
5+
For a standalone build (including harvesting), use buildmsi.ps1.
6+
-->
7+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
38
<PropertyGroup>
49
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
510
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
611
<ProductVersion>3.10</ProductVersion>
7-
<ProjectGuid>bbf5fda0-c08f-48c9-9b98-e017dd8abb5d</ProjectGuid>
812
<SchemaVersion>2.0</SchemaVersion>
9-
<OutputName>Setup</OutputName>
13+
<ProjectGuid>{BBF5FDA0-C08F-48C9-9B98-E017DD8ABB5D}</ProjectGuid>
1014
<OutputType>Package</OutputType>
11-
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
12-
</PropertyGroup>
13-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
14-
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
15-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
16-
<DefineConstants>Debug</DefineConstants>
15+
<OutputName>WorkloadTools</OutputName>
16+
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
17+
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
18+
<!-- Default version for local developer builds; buildmsi.ps1 always passes BuildVersion -->
19+
<BuildVersion Condition=" '$(BuildVersion)' == '' ">0.0.0.0</BuildVersion>
1720
</PropertyGroup>
1821
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
19-
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
20-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
21-
</PropertyGroup>
22-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
23-
<DefineConstants>Debug</DefineConstants>
24-
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
25-
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
22+
<OutputPath>bin\x86\Release\</OutputPath>
23+
<IntermediateOutputPath>obj\x86\Release\</IntermediateOutputPath>
24+
<DefineConstants>BuildVersion=$(BuildVersion);Platform=$(Platform)</DefineConstants>
2625
</PropertyGroup>
2726
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
28-
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
29-
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
27+
<OutputPath>bin\x64\Release\</OutputPath>
28+
<IntermediateOutputPath>obj\x64\Release\</IntermediateOutputPath>
29+
<DefineConstants>BuildVersion=$(BuildVersion);Platform=$(Platform)</DefineConstants>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
32+
<OutputPath>bin\x86\Debug\</OutputPath>
33+
<IntermediateOutputPath>obj\x86\Debug\</IntermediateOutputPath>
34+
<DefineConstants>BuildVersion=$(BuildVersion);Platform=$(Platform)</DefineConstants>
35+
</PropertyGroup>
36+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
37+
<OutputPath>bin\x64\Debug\</OutputPath>
38+
<IntermediateOutputPath>obj\x64\Debug\</IntermediateOutputPath>
39+
<DefineConstants>BuildVersion=$(BuildVersion);Platform=$(Platform)</DefineConstants>
3040
</PropertyGroup>
3141
<ItemGroup>
32-
<Compile Include="harvest.wxs" />
33-
<Compile Include="harvest2.wxs" />
3442
<Compile Include="Product.wxs" />
35-
</ItemGroup>
36-
<ItemGroup>
37-
<ProjectReference Include="..\ConvertWorkload\ConvertWorkload.csproj">
38-
<Name>ConvertWorkload</Name>
39-
<Project>{62e37c03-ba08-46ce-a583-d71fb7a8825b}</Project>
40-
<Private>True</Private>
41-
<DoNotHarvest>True</DoNotHarvest>
42-
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
43-
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
44-
</ProjectReference>
45-
<ProjectReference Include="..\SqlWorkload\SqlWorkload.csproj">
46-
<Name>SqlWorkload</Name>
47-
<Project>{fb46ad2c-df81-4d35-b419-d93e5ef9d98a}</Project>
48-
<Private>True</Private>
49-
<DoNotHarvest>
50-
</DoNotHarvest>
51-
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
52-
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
53-
</ProjectReference>
54-
<ProjectReference Include="..\WorkloadViewer\WorkloadViewer.csproj">
55-
<Name>WorkloadViewer</Name>
56-
<Project>{6e10e31f-d04d-4cb7-8bb9-71abd4b6b973}</Project>
57-
<Private>True</Private>
58-
<DoNotHarvest>True</DoNotHarvest>
59-
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
60-
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
61-
</ProjectReference>
43+
<!--
44+
harvest.wxs, harvest2.wxs and harvest3.wxs are generated by heat.exe
45+
in buildmsi.ps1. Run buildmsi.ps1 before building from Visual Studio.
46+
-->
47+
<Compile Include="harvest.wxs" Condition="Exists('harvest.wxs')" />
48+
<Compile Include="harvest2.wxs" Condition="Exists('harvest2.wxs')" />
49+
<Compile Include="harvest3.wxs" Condition="Exists('harvest3.wxs')" />
6250
</ItemGroup>
6351
<ItemGroup>
6452
<Content Include="postbuild.bat" />
6553
<Content Include="SignMsi.ps1" />
6654
<Content Include="transform.xsl" />
6755
<Content Include="transform2.xsl" />
56+
<Content Include="transform3.xsl" />
6857
</ItemGroup>
69-
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
70-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
71-
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
72-
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
73-
</Target>
74-
<!--
75-
To modify your build process, add your task inside one of the targets below and uncomment it.
76-
Other similar extension points exist, see Wix.targets.
77-
<Target Name="BeforeBuild">
78-
</Target>
79-
<Target Name="AfterBuild">
80-
</Target>
81-
-->
82-
<Target Name="BeforeBuild">
83-
<GetAssemblyIdentity AssemblyFiles="..\SqlWorkload\bin\$(Platform)\$(Configuration)\SqlWorkload.exe">
84-
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
85-
</GetAssemblyIdentity>
86-
<PropertyGroup>
87-
<DefineConstants>BuildVersion=%(AssemblyVersion.Version)</DefineConstants>
88-
</PropertyGroup>
89-
<HeatDirectory OutputFile="$(ProjectDir)\harvest.wxs" Directory="..\SqlWorkload\bin\$(Platform)\$(Configuration)" ComponentGroupName="ProductComponents" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" PreprocessorVariable="var.SqlWorkload.TargetDir" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" NoLogo="true" Transforms="transform.xsl" />
90-
<HeatDirectory OutputFile="$(ProjectDir)\harvest2.wxs" Directory="..\WorkloadViewer\bin\$(Platform)\$(Configuration)" ComponentGroupName="WorkloadViewerComponents" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" PreprocessorVariable="var.WorkloadViewer.TargetDir" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" NoLogo="true" Transforms="transform.xsl;transform2.xsl" />
91-
<HeatDirectory OutputFile="$(ProjectDir)\harvest3.wxs" Directory="..\ConvertWorkload\bin\$(Configuration)" ComponentGroupName="ConvertWorkloadComponents" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" PreprocessorVariable="var.ConvertWorkload.TargetDir" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" NoLogo="true" Transforms="transform.xsl;transform2.xsl" />
92-
</Target>
9358
<PropertyGroup>
94-
<PreBuildEvent />
95-
</PropertyGroup>
96-
<PropertyGroup>
97-
<PostBuildEvent>call $(ProjectDir)postbuild.bat "!(TargetPath)" "$(TargetDir)$(SolutionName)_$(Platform)$(TargetExt)"</PostBuildEvent>
59+
<PostBuildEvent>call $(ProjectDir)postbuild.bat "$(TargetPath)" "$(TargetDir)WorkloadTools_$(Platform)$(TargetExt)"</PostBuildEvent>
9860
</PropertyGroup>
61+
<Import Project="$(WixTargetsPath)" Condition="Exists('$(WixTargetsPath)')" />
62+
<Target Name="EnsureWixTargetsImported" BeforeTargets="PrepareForBuild" Condition=" '$(WixTargetsImported)' == '' ">
63+
<Warning Text="WiX Toolset v3 build targets were not found at '$(WixTargetsPath)'. Build skipped. Use buildmsi.ps1 to build the installer." />
64+
</Target>
65+
<Target Name="Build" Condition=" '$(WixTargetsImported)' == '' ">
66+
<Message Text="Setup project skipped: WiX Toolset v3 is not installed. Use buildmsi.ps1 to build the installer." Importance="high" />
67+
</Target>
9968
</Project>

0 commit comments

Comments
 (0)