Skip to content

Commit

Permalink
Configured "file harvesting" for the windows installer.
Browse files Browse the repository at this point in the history
It automatically converts the build result into
components.
  • Loading branch information
Snonky committed Apr 26, 2024
1 parent e323018 commit b60c72b
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 190 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ app.*.map.json
# Installer artifacts
installers/windows/bin
installers/windows/obj
installers/windows/cabinet/*
installers/windows/.vs

# Android Studio will place build artifacts here
Expand Down
151 changes: 5 additions & 146 deletions installers/windows/AppComponents.wxs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="AppComponents" Directory="INSTALLFOLDER">
<ComponentGroupRef Id="BinaryFiles"/>
<ComponentGroupRef Id="DataFiles"/>
<ComponentGroupRef Id="AssetFiles"/>
<ComponentGroupRef Id="CustomFontFiles"/>
<ComponentGroupRef Id="InterFontFiles"/>
<ComponentGroupRef Id="CupertinoFiles"/>
<ComponentGroupRef Id="FontAwesomeFiles"/>
<ComponentGroupRef Id="DashedBorderFiles"/>
<ComponentGroupRef Id="WindowManagerFiles"/>
<ComponentGroupRef Id="ShaderFiles"/>
<ComponentGroupRef Id="LocalServerFiles"/>

<!-- These component groups are harvested during the build. Configured in windows.wixproj HarvestDirectory and HarvestFile tags. -->
<ComponentGroupRef Id="FileComponents"/>
<ComponentGroupRef Id="ServerComponents"/>

<Component Directory="DesktopFolder"
Condition="CREATEDESKTOPSHORTCUT">
Expand All @@ -29,141 +22,7 @@

</ComponentGroup>

<ComponentGroup Id="BinaryFiles" Directory="INSTALLFOLDER">
<Component>
<File Id="ezBadminton.exe" Source="cabinet\ezBadminton.exe" />
</Component>
<Component>
<File Id="flutter_windows.dll" Source="cabinet\flutter_windows.dll" />
</Component>
<Component>
<File Id="pdfium.dll" Source="cabinet\pdfium.dll" />
</Component>
<Component>
<File Id="printing_plugin.dll" Source="cabinet\printing_plugin.dll" />
</Component>
<Component>
<File Id="screen_retriever_plugin.dll" Source="cabinet\screen_retriever_plugin.dll" />
</Component>
<Component>
<File Id="url_launcher_windows_plugin.dll" Source="cabinet\url_launcher_windows_plugin.dll" />
</Component>
<Component>
<File Id="window_manager_plugin.dll" Source="cabinet\window_manager_plugin.dll" />
</Component>
</ComponentGroup>

<ComponentGroup Id="DataFiles" Directory="DATAFOLDER">
<Component>
<File Id="app.so" Source="cabinet\data\app.so" />
</Component>
<Component>
<File Id="icudtl.dat" Source="cabinet\data\icudtl.dat" />
</Component>
</ComponentGroup>

<ComponentGroup Id="AssetFiles" Directory="ASSETFOLDER">
<Component>
<File Id="AssetManifest.bin" Source="cabinet\data\flutter_assets\AssetManifest.bin" />
</Component>
<Component>
<File Id="AssetManifest.bin.json" Source="cabinet\data\flutter_assets\AssetManifest.bin.json" />
</Component>
<Component>
<File Id="AssetManifest.json" Source="cabinet\data\flutter_assets\AssetManifest.json" />
</Component>
<Component>
<File Id="FontManifest.json" Source="cabinet\data\flutter_assets\FontManifest.json" />
</Component>
<Component>
<File Id="kernel_blob.bin" Source="cabinet\data\flutter_assets\kernel_blob.bin" />
</Component>
<Component>
<File Id="NOTICES" Source="cabinet\data\flutter_assets\NOTICES" />
</Component>
<Component>
<File Id="NOTICES.Z" Source="cabinet\data\flutter_assets\NOTICES.Z" />
</Component>
</ComponentGroup>

<ComponentGroup Id="CustomFontFiles" Directory="FONTFOLDER">
<Component>
<File Id="BadmintonIcons.ttf" Source="cabinet\data\flutter_assets\fonts\BadmintonIcons.ttf" />
</Component>
<Component>
<File Id="MaterialIcons_Regular.otf" Source="cabinet\data\flutter_assets\fonts\MaterialIcons-Regular.otf" />
</Component>
</ComponentGroup>

<ComponentGroup Id="InterFontFiles" Directory="INTERFOLDER">
<Component>
<File Id="Inter_Regular.ttf" Source="cabinet\data\flutter_assets\fonts\Inter\Inter-Regular.ttf" />
</Component>
<Component>
<File Id="Inter_Bold.ttf" Source="cabinet\data\flutter_assets\fonts\Inter\Inter-Bold.ttf" />
</Component>
</ComponentGroup>

<ComponentGroup Id="CupertinoFiles" Directory="CUPERTINOICONSASSETFOLDER">
<Component>
<File Id="CupertinoIcons.ttf" Source="cabinet\data\flutter_assets\packages\cupertino_icons\assets\CupertinoIcons.ttf" />
</Component>
</ComponentGroup>

<ComponentGroup Id="FontAwesomeFiles" Directory="FONTAWESOMEFONTSFOLDER">
<Component>
<File Id="fa_brands_400.ttf" Source="cabinet\data\flutter_assets\packages\font_awesome_flutter\lib\fonts\fa-brands-400.ttf" />
</Component>
<Component>
<File Id="fa_regular_400.ttf" Source="cabinet\data\flutter_assets\packages\font_awesome_flutter\lib\fonts\fa-regular-400.ttf" />
</Component>
<Component>
<File Id="fa_solid_900.ttf" Source="cabinet\data\flutter_assets\packages\font_awesome_flutter\lib\fonts\fa-solid-900.ttf" />
</Component>
</ComponentGroup>

<ComponentGroup Id="DashedBorderFiles" Directory="DASHEDBORDERIMAGESFOLDER">
<Component>
<File Id="type1.png" Source="cabinet\data\flutter_assets\packages\mobkit_dashed_border\images\type1.png" />
</Component>
<Component>
<File Id="type2.png" Source="cabinet\data\flutter_assets\packages\mobkit_dashed_border\images\type2.png" />
</Component>
<Component>
<File Id="type3.png" Source="cabinet\data\flutter_assets\packages\mobkit_dashed_border\images\type3.png" />
</Component>
<Component>
<File Id="type4.png" Source="cabinet\data\flutter_assets\packages\mobkit_dashed_border\images\type4.png" />
</Component>
</ComponentGroup>

<ComponentGroup Id="WindowManagerFiles" Directory="WINDOWMANAGERIMAGESFOLDER">
<Component>
<File Id="ic_chrome_close.png" Source="cabinet\data\flutter_assets\packages\window_manager\images\ic_chrome_close.png" />
</Component>
<Component>
<File Id="ic_chrome_maximize.png" Source="cabinet\data\flutter_assets\packages\window_manager\images\ic_chrome_maximize.png" />
</Component>
<Component>
<File Id="ic_chrome_minimize.png" Source="cabinet\data\flutter_assets\packages\window_manager\images\ic_chrome_minimize.png" />
</Component>
<Component>
<File Id="ic_chrome_unmaximize.png" Source="cabinet\data\flutter_assets\packages\window_manager\images\ic_chrome_unmaximize.png" />
</Component>
</ComponentGroup>

<ComponentGroup Id="ShaderFiles" Directory="SHADERFOLDER">
<Component>
<File Id="ink_sparkle.frag" Source="cabinet\data\flutter_assets\shaders\ink_sparkle.frag" />
</Component>
</ComponentGroup>

<ComponentGroup Id="LocalServerFiles" Directory="LOCALSERVERFOLDER">
<Component>
<File Id="ezBadmintonServer.exe" Source="cabinet\local_server\ezBadmintonServer.exe" />
</Component>
</ComponentGroup>

<MediaTemplate EmbedCab="yes" />

</Fragment>
</Wix>
26 changes: 26 additions & 0 deletions installers/windows/ClientExeTransform.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:param name="exeName" select="'ezBadminton.exe'"/>

<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>


<!-- Rename the client executable to ezBadminton.exe and make that name the Id of the File element to be able to create a shortcut for it -->
<xsl:template match="node()[local-name()='File'][@*[local-name()='Source'] = 'SourceDir\ez_badminton_admin_app.exe']/@*[local-name()='Id']">
<xsl:attribute name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="$exeName"/>
</xsl:attribute>
<xsl:attribute name="Name" namespace="{namespace-uri()}">
<xsl:value-of select="$exeName"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
26 changes: 1 addition & 25 deletions installers/windows/Folders.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,7 @@
<Fragment>
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.ProductName)">
<Directory Id="DATAFOLDER" Name="data">
<Directory Id="ASSETFOLDER" Name="flutter_assets">
<Directory Id="FONTFOLDER" Name="fonts">
<Directory Id="INTERFOLDER" Name="Inter"></Directory>
</Directory>
<Directory Id="PACKAGEFOLDER" Name="packages">
<Directory Id="CUPERTINOICONSFOLDER" Name="cupertino_icons">
<Directory Id="CUPERTINOICONSASSETFOLDER" Name="assets"></Directory>
</Directory>
<Directory Id="FONTAWESOMEFOLDER" Name="font_awesome_flutter">
<Directory Id="FONTAWESOMELIBFOLDER" Name="lib">
<Directory Id="FONTAWESOMEFONTSFOLDER" Name="fonts"></Directory>
</Directory>
</Directory>
<Directory Id="DASHEDBORDERFOLDER" Name="mobkit_dashed_border">
<Directory Id="DASHEDBORDERIMAGESFOLDER" Name="images"></Directory>
</Directory>
<Directory Id="WINDOWMANAGERFOLDER" Name="window_manager">
<Directory Id="WINDOWMANAGERIMAGESFOLDER" Name="images"></Directory>
</Directory>
</Directory>
<Directory Id="SHADERFOLDER" Name="shaders"></Directory>
</Directory>
</Directory>
<Directory Id="LOCALSERVERFOLDER" Name="local_server"></Directory>
<Directory Id="SERVERFOLDER" Name="local_server"></Directory>
</Directory>
</StandardDirectory>
</Fragment>
Expand Down
40 changes: 22 additions & 18 deletions installers/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@ The build uses MSBuild via Visual Studio 2022.
* Open the `windows.sln` solution in VS2022


### Provide the file cabinet
### Provide the payload files

The files in the cabinet are embedded in the installer during its build.
The files that are embedded in the installer are "harvested" from different locations during the build. The paths are defined relative to this (`installers/windows`) directory.

* Build the client (run `flutter build windows` in this repository's root directory).
* Find the build result at `[...]\ez_badminton_admin_app\build\windows\x64\runner\Release`
* Copy the files to the `cabinet` directory
* It should look something like this
```
ez_badminton_admin_app\installers\windows\cabinet
- data
- ez_badminton_admin_app.exe
- flutter_windows.dll
- ...
```
* Rename `ez_badminton_admin_app.exe` to `ezBadminton.exe`
* Download the ezBadminton server executable from the [releases](https://github.com/ezBadminton/ezBadmintonServer/releases)
* Take the windows-amd64 one
* Create a directory called `local_server` in the `cabinet` directory
* Move the server executable to `local_server`
* Rename the server executable to `ezBadmintonServer.exe`
* Verify that the build result is at `ez_badminton_admin_app\build\windows\x64\runner\Release`
* It should look something like this
```
ez_badminton_admin_app\build\windows\x64\runner\Release
- data
- ez_badminton_admin_app.exe
- flutter_windows.dll
- ...
```
* The installer build will automatically take the files from here

---

The client can run locally and has the ability to start a local server on its own. Therefore the server executable has to be included with the installer.

* Build the server or download the windows-amd64 one from the server repository's [releases](https://github.com/ezBadminton/ezBadmintonServer/releases)
* Place it in a directory named `server` one level above the repository
* Like this: `ez_badminton_admin_app\..\server\ezBadmintonServer-windows-amd64-vX.Y.Z.exe`
* The installer build will harvest it from there


### Build the installer

Expand Down
23 changes: 23 additions & 0 deletions installers/windows/ServerExeTransform.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:param name="exeName" select="'ezBadmintonServer.exe'"/>

<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>


<!-- Rename the server executable to ezBadmintonServer.exe -->
<xsl:template match="node()[local-name()='File']/@*[local-name()='Id']">
<xsl:attribute name="Name" namespace="{namespace-uri()}">
<xsl:value-of select="$exeName"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
31 changes: 31 additions & 0 deletions installers/windows/windows.wixproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
<Project Sdk="WixToolset.Sdk/5.0.0">
<ItemGroup>
<PackageReference Include="WixToolset.Heat" Version="5.0.0" />
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.0" />
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<HarvestDirectory Include="..\..\build\windows\x64\runner\Release">
<ComponentGroupName>FileComponents</ComponentGroupName>
<DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<Transforms>ClientExeTransform.xslt</Transforms>
</HarvestDirectory>
<BindPath Include="..\..\build\windows\x64\runner\Release" />
</ItemGroup>

<ItemGroup>
<HarvestFile Include="..\..\..\server\ezBadmintonServer-windows-amd64*.exe">
<ComponentGroupName>ServerComponents</ComponentGroupName>
<DirectoryRefId>SERVERFOLDER</DirectoryRefId>
<SuppressRootDirectory>true</SuppressRootDirectory>
<Transforms>ServerExeTransform.xslt</Transforms>
</HarvestFile>
<BindPath Include="..\..\..\server" />
</ItemGroup>

<ItemGroup>
<None Include="ClientExeTransform.xslt" />
<None Include="ServerExeTransform.xslt" />
</ItemGroup>

<PropertyGroup>
<HarvestFileSuppressUniqueIds>true</HarvestFileSuppressUniqueIds>
</PropertyGroup>

<PropertyGroup>
<Cultures>en-US</Cultures>
<OutputName>ezBadminton-installer-windows</OutputName>
Expand Down

0 comments on commit b60c72b

Please sign in to comment.