Add Setup Project

This commit is contained in:
2023-07-20 19:34:28 +02:00
parent cf1b1f7865
commit d43633cb65
13 changed files with 291 additions and 3 deletions

View File

@ -4,22 +4,70 @@ VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elwig", "Elwig\Elwig.csproj", "{00868460-16F6-4B48-AA9B-998F6263693B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}"
EndProject
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Setup", "Setup\Setup.wixproj", "{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|ARM64.Build.0 = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|x64.ActiveCfg = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|x64.Build.0 = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|x86.ActiveCfg = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Debug|x86.Build.0 = Debug|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|Any CPU.Build.0 = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|ARM64.ActiveCfg = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|ARM64.Build.0 = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|x64.ActiveCfg = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|x64.Build.0 = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|x86.ActiveCfg = Release|Any CPU
{00868460-16F6-4B48-AA9B-998F6263693B}.Release|x86.Build.0 = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|ARM64.Build.0 = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|x64.ActiveCfg = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|x64.Build.0 = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|x86.ActiveCfg = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Debug|x86.Build.0 = Debug|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|Any CPU.Build.0 = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|ARM64.ActiveCfg = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|ARM64.Build.0 = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|x64.ActiveCfg = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|x64.Build.0 = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|x86.ActiveCfg = Release|Any CPU
{30D7700A-7B0A-4E5D-B839-B4C1D95E307E}.Release|x86.Build.0 = Release|Any CPU
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|Any CPU.ActiveCfg = Debug|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|Any CPU.Build.0 = Debug|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|ARM64.ActiveCfg = Debug|ARM64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|ARM64.Build.0 = Debug|ARM64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|x64.ActiveCfg = Debug|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|x64.Build.0 = Debug|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|x86.ActiveCfg = Debug|x86
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Debug|x86.Build.0 = Debug|x86
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|Any CPU.ActiveCfg = Release|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|Any CPU.Build.0 = Release|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|ARM64.ActiveCfg = Release|ARM64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|ARM64.Build.0 = Release|ARM64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|x64.ActiveCfg = Release|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|x64.Build.0 = Release|x64
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|x86.ActiveCfg = Release|x86
{4A82C9C0-EB6D-409C-B0B2-09A5F727D16F}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->

View File

@ -0,0 +1,50 @@
<?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

@ -0,0 +1,12 @@
<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

@ -0,0 +1,41 @@
<?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>

4
Setup/Files/config.ini Normal file
View File

@ -0,0 +1,4 @@
[general]
[database]
file = C:\ProgramData\Elwig\database.sqlite3

23
Setup/Folders.wxs Normal file
View File

@ -0,0 +1,23 @@
<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>

12
Setup/MainComponents.wxs Normal file
View File

@ -0,0 +1,12 @@
<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>
</ComponentGroup>
</Fragment>
</Wix>

8
Setup/Package.de-at.wxl Normal file
View File

@ -0,0 +1,8 @@
<!--
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>

18
Setup/Package.wxs Normal file
View File

@ -0,0 +1,18 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Elwig" Manufacturer="Elwig" Version="0.1.0" 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>

45
Setup/Setup.wixproj Normal file
View File

@ -0,0 +1,45 @@
<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;&amp; dotnet publish "$(SolutionDir)Elwig\Elwig.csproj" "/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml"</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Cultures>de-AT</Cultures>
</PropertyGroup>
<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>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="C:\Users\tom\source\repos\elwig-cs\Elwig\Properties\PublishProfiles\FolderProfile.pubxml" Publish="true" />
<PackageReference Include="WixToolset.Heat" Version="4.0.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
<?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>