Skip to content

Commit

Permalink
Upgrade Wix Toolset to version 4 (#529)
Browse files Browse the repository at this point in the history
* Upgrade project files

* Update workflow for wix 4
  • Loading branch information
Lolle2000la authored Nov 3, 2023
1 parent 7dfe27f commit e477ffe
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 84 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ jobs:
run: dotnet build --configuration Release
- name: Test
run: dotnet test .\tests\ImageSort.UnitTests\ImageSort.UnitTests.csproj --configuration Release --no-build
- name: Setup MSBuild.exe
if: ${{ github.event_name == 'release' }}
uses: microsoft/setup-msbuild@v1
- name: Build WIX project
if: ${{ github.event_name == 'release' }}
env:
GITHUB_ACTIONS_CI: true
run: |
cd .\src\ImageSort.WindowsSetup\;
dotnet gitversion /updatewixversionfile | Out-String;
MSBuild.exe /p:Configuration=Release /p:Platform=x64 /p:OutputPath=..\..\artifacts\x64 /p:BuildProjectReferences=false | Out-String;
MSBuild.exe /p:Configuration=Release /p:Platform=x86 /p:OutputPath=..\..\artifacts\x86 /p:BuildProjectReferences=false | Out-String;
dotnet tool install --global wix
dotnet build -c Release -r win-x86 -p:Platform=x86
dotnet build -c Release -r win-x64 -p:Platform=x64
cd ..\..;
- name: Upload x86 MSI file
id: upload-x86-msi-file
Expand Down
42 changes: 12 additions & 30 deletions src/ImageSort.WindowsSetup/ImageSort.WindowsSetup.wixproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project>
<Import Project="Sdk.props" Sdk="WixToolset.Sdk" Version="4.0.2" />
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<Platform Condition=" '$(Platform)' == 'Any CPU' ">x86</Platform>
<Platform Condition=" '$(Platform)' == 'AnyCPU' ">x86</Platform>
<ProductVersion>3.11</ProductVersion>
<ProjectGuid>e23b5421-90af-437c-a2b1-73efd57283ea</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>ImageSort.$(Platform)</OutputName>
<OutputType>Package</OutputType>
<InstallerPlatform>$(Platform)</InstallerPlatform>
</PropertyGroup>
<PropertyGroup>
<OutputPath>..\..\artifacts\$(Platform)</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>Debug</DefineConstants>
Expand All @@ -23,10 +19,8 @@
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>wix\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.2" />
<PackageReference Include="WixToolset.Heat" Version="4.0.2" />
</ItemGroup>
<ItemGroup>
<Content Include="exclude-imagesort.exe.xslt" />
Expand All @@ -46,34 +40,22 @@
<Runtime>win-$(Platform)</Runtime>
</ProjectReference>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<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/" />
</Target>
<PropertyGroup>
<EnableProjectHarvesting>True</EnableProjectHarvesting>
</PropertyGroup>
<!--Fix wix on x64-->
<PropertyGroup>
<RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc>
</PropertyGroup>
<PropertyGroup>
<RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="WixToolset.Sdk" Version="4.0.2" />
<Target Name="BeforeBuild">
<Exec WorkingDirectory="%(ProjectReference.RootDir)%(ProjectReference.Directory)" Command="dotnet publish -c $(Configuration) -p:Platform=$(Platform) -f %(ProjectReference.TargetFrameworkIdentifier) -r %(ProjectReference.Runtime)" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" />
<ItemGroup>
<LinkerBindInputPaths Include="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Platform)\$(SpecialFolderPath)$(Configuration)\%(ProjectReference.TargetFrameworkIdentifier)\%(ProjectReference.Runtime)\publish" />
</ItemGroup>
<HeatDirectory DirectoryRefId="INSTALLFOLDER" RunAsSeparateProcess="$(RunWixToolsOutOfProc)" OutputFile="obj\$(Configuration)\%(ProjectReference.Name).wxs" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Platform)\$(SpecialFolderPath)$(Configuration)\%(ProjectReference.TargetFrameworkIdentifier)\%(ProjectReference.Runtime)\publish" ComponentGroupName="SourceComponentGroup" ToolPath="$(WixToolPath)" Transforms="exclude-imagesort.exe.xslt" AutogenerateGuids="true" SuppressCom="True" SuppressRegistry="True" SuppressFragments="true" SuppressRootDirectory="true" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" />
<HeatDirectory DirectoryRefId="INSTALLFOLDER" OutputFile="obj\$(Configuration)\%(ProjectReference.Name).wxs" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Platform)\$(SpecialFolderPath)$(Configuration)\%(ProjectReference.TargetFrameworkIdentifier)\%(ProjectReference.Runtime)\publish" ComponentGroupName="SourceComponentGroup" ToolPath="$(WixToolPath)" Transforms="exclude-imagesort.exe.xslt" AutogenerateGuids="true" SuppressCom="True" SuppressRegistry="True" SuppressFragments="true" SuppressRootDirectory="true" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" />
<ItemGroup>
<Compile Include="obj\$(Configuration)\%(ProjectReference.Name).wxs" Condition="'%(ProjectReference.IsDotnetSDKProject)' == 'True'" />
</ItemGroup>
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
79 changes: 32 additions & 47 deletions src/ImageSort.WindowsSetup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<?ifdef env.GITHUB_ACTIONS_CI ?>
<?include GitVersion_WixVersion.wxi ?>
<?else ?>
<?else?>
<?define AssemblySemFileVer="2.0.0.0" ?>
<?endif ?>
<?endif?>

<?if $(var.Platform)=x64 ?>
<?define win64Flag = "yes" ?>
<?define ProgramFilesFolder="ProgramFiles64Folder"?>
<?define PlatformSpecialFolder="x64\"?>
<?else ?>
<?else?>
<?define win64Flag = "no" ?>
<?define ProgramFilesFolder="ProgramFilesFolder"?>
<?define PlatformSpecialFolder="x86\"?>
<?endif ?>
<?endif?>

<Product Id="*" Name="Image Sort" Language="1033" Version="$(var.AssemblySemFileVer)" Manufacturer="Lolle2000la" UpgradeCode="1AC9D063-74DA-4D56-BA4A-C7F4216CFAF3">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Image Sort installer"
Manufacturer="Lolle2000la"/>
<Package Name="Image Sort" Language="1033" Version="$(var.AssemblySemFileVer)" Manufacturer="Lolle2000la" UpgradeCode="1AC9D063-74DA-4D56-BA4A-C7F4216CFAF3" InstallerVersion="200">
<SummaryInformation Description="Image Sort installer" Manufacturer="Lolle2000la" />

<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

Check warning on line 21 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

ICE61: This product should remove only older versions of itself. The Maximum version is not less than the current product. (2.12.5.0 2.12.5.0)

Check warning on line 21 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

ICE61: This product should remove only older versions of itself. The Maximum version is not less than the current product. (2.12.5.0 2.12.5.0)
<MediaTemplate EmbedCab="yes" />
Expand All @@ -27,83 +25,70 @@
<ComponentGroupRef Id="ProductComponents" />
</Feature>

<UIRef Id="WixUI_InstallDir"/>
<ui:WixUI Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />

<Icon Id="ImageSort.exe" SourceFile="Image Sort.exe"/>
<Icon Id="ImageSort.exe" SourceFile="Image Sort.exe" />

<Icon Id="icon.ico" SourceFile="Image Sort.ico"/>
<Icon Id="icon.ico" SourceFile="Image Sort.ico" />
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
</Product>
</Package>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesFolder)">

Check warning on line 41 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

It is no longer necessary to define the standard directory 'ProgramFilesFolder'. Use the StandardDirectory element instead.

Check warning on line 41 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

It is no longer necessary to define the standard directory 'ProgramFilesFolder'. Use the StandardDirectory element instead.
<Directory Id="INSTALLFOLDER" Name="Image Sort" />
</Directory>
<Directory Id="StartMenuFolder" Name="StartMenu"/>
<Directory Id="DesktopFolder" Name="Desktop"/>
</Directory>
</Fragment>
<StandardDirectory Id="StartMenuFolder" />
<StandardDirectory Id="DesktopFolder" />
</Fragment>

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!--<Component Id="ProductComponent" Guid="B839CE01-30EC-431F-AD54-1521B29E65DE">
</Component>-->
<Component Id="LicenseComponent" Guid="9B1F604F-1FA3-43BF-9EB0-E71565ADE974">
<File Id="LicenseRtf" Name="License.rtf" Source="License.rtf" KeyPath="yes"/>
<File Id="LicenseRtf" Name="License.rtf" Source="License.rtf" KeyPath="yes" />
</Component>
<Component Id="ImageSortExeComponent" Guid="036C3C1A-FA77-46CD-97F9-26653E110D8F">
<File Id="ImageSortExe" Name="Image Sort.exe" Source="..\ImageSort.WPF\bin\$(var.PlatformSpecialFolder)$(var.Configuration)\net7.0-windows\win-$(var.Platform)\publish\Image Sort.exe"
KeyPath="yes">
<Shortcut Id="StartMenuShortcut" Directory="StartMenuFolder" Name="Image Sort"
WorkingDirectory="INSTALLFOLDER" Advertise="yes" Icon="ImageSort.exe" IconIndex="0"/>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="Image Sort"
WorkingDirectory="INSTALLFOLDER" Advertise="yes" Icon="ImageSort.exe" IconIndex="0"/>
<File Id="ImageSortExe" Name="Image Sort.exe" Source="..\ImageSort.WPF\bin\$(var.PlatformSpecialFolder)$(var.Configuration)\net7.0-windows\win-$(var.Platform)\publish\Image Sort.exe" KeyPath="yes">
<Shortcut Id="StartMenuShortcut" Directory="StartMenuFolder" Name="Image Sort" WorkingDirectory="INSTALLFOLDER" Advertise="yes" Icon="ImageSort.exe" IconIndex="0" />
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="Image Sort" WorkingDirectory="INSTALLFOLDER" Advertise="yes" Icon="ImageSort.exe" IconIndex="0" />
</File>
</Component>
<ComponentGroupRef Id="SourceComponentGroup" />
<!--Add "Open with Image Sort" to explorer-->
<Component Id="OpenWithImageSortComponent" Guid="A54BFEA9-DA6F-4AF8-AA0C-045E0E0142EC">
<RegistryKey Root="HKCU"
Key="Software\Classes\Directory\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort" KeyPath="yes"/>
<RegistryValue Type="expandable" Name="Icon" Value='"[#ImageSortExe]"'/>
<RegistryKey Root="HKCU" Key="Software\Classes\Directory\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort" KeyPath="yes" />
<RegistryValue Type="expandable" Name="Icon" Value="&quot;[#ImageSortExe]&quot;" />

Check warning on line 66 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

ICE69: Mismatched component reference. Entry 'regq_dKM9kQ19R5LCeBS9DvR5ruyTw' of the Registry table belongs to component 'OpenWithImageSortComponent'. However, the formatted string in column 'Value' references file 'ImageSortExe' which belongs to component 'ImageSortExeComponent'. Components are in the same feature.

Check warning on line 66 in src/ImageSort.WindowsSetup/Product.wxs

View workflow job for this annotation

GitHub Actions / build

ICE69: Mismatched component reference. Entry 'regq_dKM9kQ19R5LCeBS9DvR5ruyTw' of the Registry table belongs to component 'OpenWithImageSortComponent'. However, the formatted string in column 'Value' references file 'ImageSortExe' which belongs to component 'ImageSortExeComponent'. Components are in the same feature.
<RegistryKey Key="command">
<RegistryValue Type="expandable" Value='"[#ImageSortExe] "%L""'/>
<RegistryValue Type="expandable" Value="&quot;[#ImageSortExe] &quot;%L&quot;&quot;" />
</RegistryKey>
</RegistryKey>
<RegistryKey Root="HKCU"
Key="Software\Classes\Drive\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort"/>
<RegistryValue Type="expandable" Name="Icon" Value='"[#ImageSortExe]"'/>
<RegistryKey Root="HKCU" Key="Software\Classes\Drive\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort" />
<RegistryValue Type="expandable" Name="Icon" Value="&quot;[#ImageSortExe]&quot;" />
<RegistryKey Key="command">
<RegistryValue Type="expandable" Value='"[#ImageSortExe] "%L""'/>
<RegistryValue Type="expandable" Value="&quot;[#ImageSortExe] &quot;%L&quot;&quot;" />
</RegistryKey>
</RegistryKey>
<RegistryKey Root="HKCU"
Key="Software\Classes\Folder\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort"/>
<RegistryValue Type="expandable" Name="Icon" Value='"[#ImageSortExe]"'/>
<RegistryKey Root="HKCU" Key="Software\Classes\Folder\shell\ImageSort">
<RegistryValue Type="expandable" Value="Open with Image Sort" />
<RegistryValue Type="expandable" Name="Icon" Value="&quot;[#ImageSortExe]&quot;" />
<RegistryKey Key="command">
<RegistryValue Type="expandable" Value='"[#ImageSortExe]" "%L"'/>
<RegistryValue Type="expandable" Value="&quot;[#ImageSortExe]&quot; &quot;%L&quot;" />
</RegistryKey>
</RegistryKey>
</Component>
</ComponentGroup>

<CustomAction Id="EXECUTE_AFTER_FINALIZE"
Execute="immediate"
Impersonate="yes"
Return="asyncNoWait"
FileKey="ImageSortExe"
ExeCommand="" />
<CustomAction Id="EXECUTE_AFTER_FINALIZE" Execute="immediate" Impersonate="yes" Return="asyncNoWait" ExeCommand="" FileRef="ImageSortExe" />

<InstallExecuteSequence>
<Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize">(AUTOSTART=1)</Custom>
<Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize" Condition="(AUTOSTART=1)" />
</InstallExecuteSequence>
</Fragment>
</Wix>
4 changes: 2 additions & 2 deletions src/ImageSort.WindowsSetup/exclude-imagesort.exe.xslt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"
xmlns="http://wixtoolset.org/schemas/v4/wxs"

version="1.0"
exclude-result-prefixes="xsl wix">
Expand Down

0 comments on commit e477ffe

Please sign in to comment.