Moved building MSI to Installer and created Bootstrapper in Setup

This commit is contained in:
2023-08-21 19:43:29 +02:00
parent 4aa8fe2e2d
commit 0e13e269d0
13 changed files with 129 additions and 48 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>

25
Setup/Bundle.wxs Normal file
View File

@ -0,0 +1,25 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Bundle Name="Elwig" Manufacturer="Elwig" Version="!(bind.packageVersion.ElwigMsi)" UpgradeCode="f3c8fcab-c37c-43aa-9ab8-e42f4bb518b7" IconSourceFile="$(var.ElwigProjectDir)\elwig.ico" >
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" LogoFile="$(var.ElwigProjectDir)\elwig.png" SuppressOptionsUI="yes" ShowVersion="yes" />
</BootstrapperApplication>
<util:RegistrySearch Id="VCredistx86" Variable="VCredistx86" Result="exists" Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\VC,redist.x86,x86,14.36,bundle" />
<util:RegistrySearch Id="Webview2Machine" Variable="Webview2Machine" Result="exists" Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" />
<util:RegistrySearch Id="Webview2User" Variable="Webview2User" Result="exists" Root="HKCU" Key="Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" />
<Chain>
<ExePackage Id="VCredistx86Installer" DisplayName="VC Redist x86 installer" Name="VC_redist.x86.exe" Cache="remove" Compressed="yes" PerMachine="yes"
Permanent="yes" Vital="yes" SourceFile="$(TargetDir)VC_redist.x86.exe" InstallArguments="/install /passive /norestart" DetectCondition="VCredistx86">
</ExePackage>
<ExePackage Id="MicrosoftEdgeWebview2" DisplayName="Microsoft Edge Webview2 Runtime" Name="MicrosoftEdgeWebview2Setup.exe" Cache="remove"
Compressed="yes" PerMachine="yes" Permanent ="yes" Vital ="no" SourceFile="$(TargetDir)MicrosoftEdgeWebview2Setup.exe" InstallArguments="/silent /install"
UninstallArguments="/silent /uninstall" DetectCondition="Webview2Machine OR Webview2User" >
</ExePackage>
<MsiPackage Id="ElwigMsi" SourceFile="$(var.Installer.TargetDir)\Elwig.msi" Permanent="no" Compressed="yes" Vital="yes"/>
</Chain>
</Bundle>
</Wix>

View File

@ -1,12 +0,0 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="DocumentTemplateComponents" Directory="ConfigFolderResources">
<Component>
<File Source="$(TargetDir)\paged.polyfill.js" />
</Component>
<Component>
<File Source="$(var.Elwig.ProjectDir)\Documents\style.css" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>

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 ) - 6 ) != '.cshtml' ]"
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. -->
<!-- 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

@ -1,30 +0,0 @@
[general]
; Only needed, if more than one branch is stored in database
branch = Zweigstelle
[database]
; Relative or absolute path to database file
file = database.sqlite3
; Enables database logging
;log = db.log
;[scale.1]
;type = systec
;model = IT3000A
;connection = serial://COM1:9600,8,N,1
;empty = COM2:RTS:1000
;filling = DTR
; Limit on when the filling clearance should be removed
;limit = 3500
; Enables scale logging
;log = waage.log
;[scale.B]
;type = Type
;model = Model
;connection = tcp://10.0.0.1:1234
;empty = OUT1:3000
;filling = OUT2
; Limit on when the filling clearance should be removed
;limit = 3000

View File

@ -1,23 +0,0 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<!-- C:\Program Files (x86)\Elwig oder C:\Program Files\Elwig -->
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="InstallFolder" Name="!(bind.Property.ProductName)" />
</StandardDirectory>
<!-- C:\ProgramData\Elwig -->
<StandardDirectory Id="CommonAppDataFolder">
<Directory Id="ConfigFolder" Name="!(bind.Property.ProductName)">
<Directory Id="ConfigFolderResources" Name="resources" />
</Directory>
</StandardDirectory>
<!-- C:\ProgramData\Microsoft\Windows\Start Menu\Programs -->
<StandardDirectory Id="ProgramMenuFolder">
<Directory Id="StartMenuProgramsFolder" Name="!(bind.Property.ProductName)" />
</StandardDirectory>
<!-- C:\Users{USERNAME}\Desktop -->
<StandardDirectory Id="DesktopFolder" />
</Fragment>
</Wix>

View File

@ -1,15 +0,0 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="MainComponents">
<Component Directory="InstallFolder">
<File Source="$(var.Elwig.ProjectDir)\bin\Publish\Elwig.exe" Id="Elwig.exe"/>
</Component>
<Component Directory="ConfigFolder" Permanent="true" NeverOverwrite="true">
<File Source="$(ProjectDir)\Files\config.ini" Id="config.ini"/>
</Component>
<Component Directory="InstallFolder">
<File Source="$(TargetDir)\PDFtoPrinter.exe" Id="PDFtoPrinter.exe"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>

View File

@ -1,8 +0,0 @@
<!--
This file contains the declaration of all the localizable strings.
-->
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="de-AT">
<String Id="DowngradeError" Value="Eine neuere Version von [ProductName] ist bereits installiert." />
</WixLocalization>

View File

@ -1,17 +0,0 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Elwig" Manufacturer="Elwig" Version="!(bind.FileVersion.Elwig.exe)" Language="3079" UpgradeCode="a459416a-756a-4be6-b6f4-40872c8425a7" Compressed="true">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
<MediaTemplate EmbedCab="true"/>
<Icon Id="icon.ico" SourceFile="$(var.Elwig.ProjectDir)\elwig.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico"/>
<Feature Id="Main">
<ComponentGroupRef Id="ShortcutComponents"/>
<ComponentGroupRef Id="MainComponents"/>
<ComponentGroupRef Id="BuildFiles"/>
<ComponentGroupRef Id="DocumentTemplates"/>
<ComponentGroupRef Id="DocumentTemplateComponents"/>
</Feature>
</Package>
</Wix>

View File

@ -1,47 +1,19 @@
<Project Sdk="WixToolset.Sdk/4.0.1">
<Project Sdk="WixToolset.Sdk/4.0.1">
<PropertyGroup>
<HarvestFileSuppressUniqueIds>false</HarvestFileSuppressUniqueIds>
<HarvestFileGenerateGuidsNow>true</HarvestFileGenerateGuidsNow>
<HarvestDirectorySuppressRegistry>false</HarvestDirectorySuppressRegistry>
<HarvestDirectoryVerboseOutput>true</HarvestDirectoryVerboseOutput>
<HarvestProjectsDirectoryIds>InstallFolder</HarvestProjectsDirectoryIds>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>BuildPath=../Elwig/bin/Publish;DocumentTemplatesPath=../Elwig/Documents</DefineConstants>
<PreBuildEvent>curl -s -L "https://unpkg.com/pagedjs/dist/paged.polyfill.js" -o "$(TargetDir)paged.polyfill.js" &amp; curl -s "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "$(TargetDir)PDFtoPrinter.exe" -o "$(TargetDir)PDFtoPrinter.exe" &amp; dotnet publish "$(SolutionDir)Elwig\Elwig.csproj" "/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml"</PreBuildEvent>
<OutputType>Bundle</OutputType>
<OutputName>Elwig</OutputName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Cultures>de-AT</Cultures>
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
<Exec Command='curl -L -s "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' />
<Exec Command='curl -L -s "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' />
<PropertyGroup>
<DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants>
</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" />
<ProjectReference Include="..\Installer\Installer.wixproj" />
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.1" />
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<HarvestDirectory Include="../Elwig/Documents">
<ComponentGroupName>DocumentTemplates</ComponentGroupName>
<DirectoryRefId>ConfigFolderResources</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<PreprocessorVariable>DocumentTemplatesPath</PreprocessorVariable>
<Transforms>DocumentTemplatesTransform.xslt</Transforms>
</HarvestDirectory>
<BindPath BindName="DocumentTemplateBindPath" Include="../Elwig/Documents" />
</ItemGroup>
<ItemGroup>
<None Include="DocumentTemplatesTransform.xslt" />
<None Include="BuildFilesTransform.xslt" />
<None Include="Files\config.ini" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elwig\Elwig.csproj" PublishProfile="..\Elwig\Properties\PublishProfiles\FolderProfile.pubxml" Publish="true" />
<PackageReference Include="WixToolset.Heat" Version="4.0.1" />
</ItemGroup>
</Project>
</Project>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="ShortcutComponents">
<Component Id="StartMenuFolderShortcut" Directory="StartMenuProgramsFolder" Guid="d21fc601-55f3-44bf-9b36-d0971dd9452d">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="!(bind.Property.ProductName)"
Description="!(bind.Property.ProductName)"
Icon="icon.ico"
Target="[#Elwig.exe]"
WorkingDirectory="InstallFolder"/>
<RemoveFolder Id="StartMenuProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\!(bind.Property.Manufacturer)\!(bind.Property.ProductName)" Name="start_menu_installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
<Component Id="DesktopFolderShortcut" Directory="DesktopFolder" Guid="b7a88e37-a62f-4c60-9464-bd0b384f9803">
<Shortcut Id="DesktopShortcut"
Name="!(bind.Property.ProductName)"
Description="!(bind.Property.ProductName)"
Icon="icon.ico"
Target="[#Elwig.exe]"
WorkingDirectory="InstallFolder"/>
<RegistryValue Root="HKCU" Key="Software\!(bind.Property.Manufacturer)\!(bind.Property.ProductName)" Name="desktop_installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>