Migrate Installer and Setup to Wix 5

This commit is contained in:
2024-05-03 21:27:27 +02:00
committed by Lorenz Stechauner
parent d102a1cb7a
commit 384f7c9ec0
7 changed files with 22 additions and 123 deletions

View File

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"
xmlns="http://wixtoolset.org/schemas/v4/wxs"
version="1.0"
exclude-result-prefixes="xsl wix">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<!--
Find all <Component> elements with <File> elements with Source="" attributes ending in ".exe" and tag it with the "ExeToRemove" key.
<Component Id="cmpSYYKP6B1M7WSD5KLEQ7PZW4YLOPYG61L" Directory="INSTALLDIR" Guid="*">
<File Id="filKUS7ZRMJ0AOKDU6ATYY6IRUSR2ECPDFO" KeyPath="yes" Source="!(wix.StagingAreaPath)\ProofOfPEqualsNP.exe" />
</Component>
Because WiX's Heat.exe only supports XSLT 1.0 and not XSLT 2.0 we cannot use `ends-with( haystack, needle )` (e.g. `ends-with( wix:File/@Source, '.exe' )`...
...but we can use this longer `substring` expression instead (see https://github.com/wixtoolset/issues/issues/5609 )
-->
<xsl:key
name="ExeToRemove"
match="wix:Component[ substring( wix:File/@Source, string-length( wix:File/@Source ) - 3 ) = '.exe' ]"
use="@Id"
/>
<!-- Get the last 4 characters of a string using `substring( s, len(s) - 3 )`, it uses -3 and not -4 because XSLT uses 1-based indexes, not 0-based indexes. -->
<!-- We can also remove .pdb files too, for example: -->
<xsl:key
name="PdbToRemove"
match="wix:Component[ substring( wix:File/@Source, string-length( wix:File/@Source ) - 3 ) = '.pdb' ]"
use="@Id"
/>
<!-- By default, copy all elements and nodes into the output... -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- ...but if the element has the "ExeToRemove" key then don't render anything (i.e. removing it from the output) -->
<xsl:template match="*[ self::wix:Component or self::wix:ComponentRef ][ key( 'ExeToRemove', @Id ) ]" />
<xsl:template match="*[ self::wix:Component or self::wix:ComponentRef ][ key( 'PdbToRemove', @Id ) ]" />
</xsl:stylesheet>

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"
xmlns="http://wixtoolset.org/schemas/v4/wxs"
version="1.0"
exclude-result-prefixes="xsl wix">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<!--
Find all <Component> elements with <File> elements with Source="" attributes ending in ".exe" and tag it with the "ExeToRemove" key.
<Component Id="cmpSYYKP6B1M7WSD5KLEQ7PZW4YLOPYG61L" Directory="INSTALLDIR" Guid="*">
<File Id="filKUS7ZRMJ0AOKDU6ATYY6IRUSR2ECPDFO" KeyPath="yes" Source="!(wix.StagingAreaPath)\ProofOfPEqualsNP.exe" />
</Component>
Because WiX's Heat.exe only supports XSLT 1.0 and not XSLT 2.0 we cannot use `ends-with( haystack, needle )` (e.g. `ends-with( wix:File/@Source, '.exe' )`...
...but we can use this longer `substring` expression instead (see https://github.com/wixtoolset/issues/issues/5609 )
-->
<xsl:key
name="FileToRemove"
match="wix:Component[ substring( wix:File/@Source, string-length( wix:File/@Source ) - 2 ) = '.cs' ]"
use="@Id"
/>
<!-- Get the last 3 characters of a string using `substring( s, len(s) - 2 )`, it uses -2 and not -3 because XSLT uses 1-based indexes, not 0-based indexes. -->
<!-- By default, copy all elements and nodes into the output... -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- ...but if the element has the "ExeToRemove" key then don't render anything (i.e. removing it from the output) -->
<xsl:template match="*[ self::wix:Component or self::wix:ComponentRef ][ key( 'FileToRemove', @Id ) ]" />
</xsl:stylesheet>

View File

@ -2,7 +2,7 @@
<Fragment>
<!-- C:\Program Files (x86)\Elwig oder C:\Program Files\Elwig -->
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="InstallFolder" Name="!(bind.Property.ProductName)" />
<Directory Id="InstallFolder" Name="!(bind.Property.ProductName)" />
</StandardDirectory>
<!-- C:\ProgramData\Elwig -->

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="HeatComponents">
<Files Directory="InstallFolder" Include="..\Elwig\bin\Publish\**">
<Exclude Files="..\Elwig\bin\Publish\**.exe" />
<Exclude Files="..\Elwig\bin\Publish\**.pdb" />
</Files>
<Files Directory="ConfigFolderResources" Include="..\Elwig\Documents\**">
<Exclude Files="..\Elwig\Documents\**.cs" />
</Files>
</ComponentGroup>
</Fragment>
</Wix>

View File

@ -1,4 +1,4 @@
<Project Sdk="WixToolset.Sdk/4.0.1">
<Project Sdk="WixToolset.Sdk/5.0.0">
<PropertyGroup>
<HarvestFileSuppressUniqueIds>false</HarvestFileSuppressUniqueIds>
<HarvestFileGenerateGuidsNow>true</HarvestFileGenerateGuidsNow>
@ -35,31 +35,8 @@
</PropertyGroup>
</Target>
<ItemGroup>
<HarvestDirectory Include="../Elwig/bin/Publish">
<ComponentGroupName>BuildFiles</ComponentGroupName>
<DirectoryRefId>InstallFolder</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<PreprocessorVariable>BuildPath</PreprocessorVariable>
<Transforms>BuildFilesTransform.xslt</Transforms>
</HarvestDirectory>
<BindPath BindName="BuildBindPath" Include="../Elwig/bin/Publish" />
</ItemGroup>
<ItemGroup>
<HarvestDirectory Include="../Elwig/Documents">
<ComponentGroupName>DocumentTemplates</ComponentGroupName>
<DirectoryRefId>ConfigFolderResources</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<PreprocessorVariable>DocumentPath</PreprocessorVariable>
<Transforms>DocumentTransform.xslt</Transforms>
</HarvestDirectory>
<BindPath BindName="DocumentTemplateBindPath" Include="../Elwig/Documents" />
</ItemGroup>
<ItemGroup>
<None Include="DocumentTransform.xslt" />
<None Include="BuildFilesTransform.xslt" />
<None Include="Files\config.ini" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Heat" Version="5.0.0" />
<None Include="Files\PDFtoPrinter.exe" />
<None Include="Files\WinziPrint.exe" />
</ItemGroup>
</Project>

View File

@ -9,8 +9,7 @@
<Feature Id="Main">
<ComponentGroupRef Id="ShortcutComponents"/>
<ComponentGroupRef Id="MainComponents"/>
<ComponentGroupRef Id="BuildFiles"/>
<ComponentGroupRef Id="DocumentTemplates"/>
<ComponentGroupRef Id="HeatComponents"/>
</Feature>
</Package>
</Wix>

View File

@ -1,4 +1,4 @@
<Project Sdk="WixToolset.Sdk/4.0.1">
<Project Sdk="WixToolset.Sdk/5.0.0">
<PropertyGroup>
<OutputType>Bundle</OutputType>
<OutputName>Elwig</OutputName>
@ -13,7 +13,7 @@
</Target>
<ItemGroup>
<ProjectReference Include="..\Installer\Installer.wixproj" />
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.5" />
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.5" />
<PackageReference Include="WixToolset.Bal.wixext" Version="5.0.0" />
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.0" />
</ItemGroup>
</Project>