Skip to content

Commit

Permalink
[Server.Setup] Upgrade to wix v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Feb 13, 2024
1 parent dbf01b8 commit 093c546
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 165 deletions.
88 changes: 19 additions & 69 deletions CastIt.Server.Setup/CastIt.Server.Setup.wixproj
Original file line number Diff line number Diff line change
@@ -1,106 +1,56 @@
<?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.4" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>a8a568fc-1841-48cb-948e-16887f96602e</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CastItServerSetup-$(Configuration)-$(Platform)-</OutputName>
<OutputType>Package</OutputType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<!--This makes the output installer will be in a folder that is not culture specific-->
<Cultures>;</Cultures>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<!--This is the installer version, you should manually change it when creating a new installer-->
<InstallerVersion>1.0.0</InstallerVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Directories.wxs" />
<Compile Include="ServerAutoGeneratedComponents.wxs" />
<Compile Include="Product.wxs" />
<Compile Include="ServerComponents.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixFirewallExtension">
<HintPath>$(WixExtDir)\WixFirewallExtension.dll</HintPath>
<Name>WixFirewallExtension</Name>
</WixExtension>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
<PackageReference Include="WixToolset.Firewall.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Heat" Version="4.0.4" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization.wxl" />
</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>
<!--
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.
-->
<PropertyGroup>
<DefineConstants>$(DefineConstants);ServerBasePath=Publish</DefineConstants>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="WixToolset.Sdk" Version="4.0.4" />
<Target Name="BeforeBuild">
<!--First we clean delete the bin directories-->
<Exec Command="if exist Publish rd /s /q Publish">
</Exec>
<Exec Command="rd /s /q ..\CastIt.Server\bin\">
</Exec>
<Exec Command="rd /s /q ..\CastIt.Server.Windows.TrayIcon\bin\">
</Exec>
<Exec Command="if exist Publish rd /s /q Publish"></Exec>
<Exec Command="rd /s /q ..\CastIt.Server\bin\"></Exec>
<Exec Command="rd /s /q ..\CastIt.Server.Windows.TrayIcon\bin\"></Exec>
<!--Then, we publish our apps-->
<!--First the server-->
<Exec Condition="$(Configuration) != 'Debug'" Command="dotnet publish ../CastIt.Server/CastIt.Server.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -p:PublishTrimmed=true -o Publish">
</Exec>
<Exec Condition="$(Configuration) == 'Debug'" Command="dotnet publish ../CastIt.Server/CastIt.Server.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish">
</Exec>
<Exec Command="dotnet publish ../CastIt.Server/CastIt.Server.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish"></Exec>
<!--Then the tray icon-->
<Exec Condition="$(Configuration) != 'Debug'" Command="dotnet publish ../CastIt.Server.Windows.TrayIcon/CastIt.Server.Windows.TrayIcon.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish\TrayIcon">
</Exec>
<Exec Condition="$(Configuration) == 'Debug'" Command="dotnet publish ../CastIt.Server.Windows.TrayIcon/CastIt.Server.Windows.TrayIcon.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish\TrayIcon">
</Exec>
<!-- Now we move out the .exe to avoid the heat command to generate a file for it -->
<Exec Command="move Publish\CastIt.Server.exe CastIt.Server.exe">
</Exec>
<Exec Command="dotnet publish ../CastIt.Server.Windows.TrayIcon/CastIt.Server.Windows.TrayIcon.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish\TrayIcon"></Exec>
<!-- Now we move out the .exe to avoid the heat command to generate a file for it -->
<Exec Command="move Publish\CastIt.Server.exe CastIt.Server.exe"></Exec>
<!--Here we get the assembly versions-->
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Server\bin\$(Configuration)\net6.0\win-$(Platform)\CastIt.Server.dll">
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Server\bin\$(Configuration)\net8.0\win-$(Platform)\CastIt.Server.dll">
<Output TaskParameter="Assemblies" ItemName="ServerAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>$(DefineConstants);InstallerVersion=%(ServerAssembly.Version)</DefineConstants>
</PropertyGroup>
<!--We pick up all the files that we want to publish, and create an autogenerated component-->
<HeatDirectory OutputFile="ServerAutoGeneratedComponents.wxs" DirectoryRefId="ServerInstallFolder" ComponentGroupName="ServerAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.ServerBasePath" RunAsSeparateProcess="true" />
<!-- Finally we move back the .exe file -->
<Exec Command="move CastIt.Server.exe Publish\CastIt.Server.exe">
</Exec>
<HeatDirectory OutputFile="ServerAutoGeneratedComponents.wxs" DirectoryRefId="ServerInstallFolder" ComponentGroupName="ServerAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.ServerBasePath" />
<!-- Finally we move back the .exe file -->
<Exec Command="move CastIt.Server.exe Publish\CastIt.Server.exe"></Exec>
</Target>
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Server\bin\$(Configuration)\net6.0\win-$(Platform)\CastIt.Server.dll">
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Server\bin\$(Configuration)\net8.0\win-$(Platform)\CastIt.Server.dll">
<Output TaskParameter="Assemblies" ItemName="ServerAssembly" />
</GetAssemblyIdentity>
<Exec Command="if not exist Installers mkdir Installers" />
Expand Down
21 changes: 9 additions & 12 deletions CastIt.Server.Setup/Directories.wxs
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<!--Start menu-->
<Directory Id="ProgramMenuFolder">
<Directory Id="InstallMenuFolder" Name="!(loc.ProductName)"/>
</Directory>
<StandardDirectory Id="ProgramMenuFolder">
<Directory Id="InstallMenuFolder" Name="!(loc.ProductName)" />
</StandardDirectory>

<!--If 64 bits-->
<?if $(var.Platform)=x64?>
<Directory Id="ProgramFiles64Folder">
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="ServerInstallFolder" Name="Server" />
</Directory>
</Directory>
</StandardDirectory>
<!--Else 32 bits-->
<?else?>
<Directory Id="ProgramFilesFolder">
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="ServerInstallFolder" Name="Server" />
</Directory>
</Directory>
</StandardDirectory>
<?endif?>
</Directory>
</Fragment>
</Fragment>
</Wix>
27 changes: 13 additions & 14 deletions CastIt.Server.Setup/Localization.wxl
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="ProductName">CastIt</String>
<String Id="FullProductName">CastIt.Server</String>
<String Id="ProductName_x86">CastIt.Server (32 bits)</String>
<String Id="ProductName_x64">CastIt.Server (64 bits)</String>
<String Id="Company">MiraiSoft</String>
<String Id="Description">The CastIt Server</String>
<String Id="Comments">Made with love</String>
<String Id="Keywords">Desktop, .Net Core, CLI</String>
<String Id="Languages">1033</String>
<String Id="Ok">Ok</String>
<String Id="Launch">Launch</String>
<WixLocalization Culture="en-us" xmlns="http://wixtoolset.org/schemas/v4/wxl">
<String Id="ProductName" Value="CastIt" />
<String Id="FullProductName" Value="CastIt.Server" />
<String Id="ProductName_x86" Value="CastIt.Server (32 bits)" />
<String Id="ProductName_x64" Value="CastIt.Server (64 bits)" />
<String Id="Company" Value="MiraiSoft" />
<String Id="Description" Value="The CastIt Server" />
<String Id="Comments" Value="Made with love" />
<String Id="Keywords" Value="Desktop, .Net Core, CLI" />
<String Id="Languages" Value="1033" />
<String Id="Ok" Value="Ok" />
<String Id="Launch" Value="Launch" />

<String Id="DowngradeErrorMsg">A newer version of CastIt Server is already installed.</String>
<String Id="DowngradeErrorMsg" Value="A newer version of CastIt Server is already installed." />
</WixLocalization>
43 changes: 12 additions & 31 deletions CastIt.Server.Setup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
<?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">

<!--Do not modify this upgrade code-->
<?define ProductUpgradeCode = "{E421DA7A-10C9-4065-BB1A-1C5805ABD593}" ?>

<Product
Id="*"
Name="!(loc.ProductName_$(var.Platform))"
Language="1033"
Version="$(var.InstallerVersion)"
Manufacturer="!(loc.Company)"
UpgradeCode="$(var.ProductUpgradeCode)">

<Package
InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="$(var.Platform)"
Manufacturer="!(loc.Company)"
Description="!(loc.Description)"
Comments="!(loc.Comments)"
Keywords="!(loc.Keywords)"
Languages="!(loc.Languages)"/>

<Icon Id="icon.ico" SourceFile="../CastIt/favicon.ico"/>
<Property Id="ARPPRODUCTICON">icon.ico</Property>
<Property Id="ARPURLINFOABOUT">https://github.com/Wolfteam/CastIt</Property>
<Package Name="!(loc.ProductName_$(var.Platform))" Language="1033" Version="$(var.InstallerVersion)" Manufacturer="!(loc.Company)" UpgradeCode="$(var.ProductUpgradeCode)" InstallerVersion="200">

<SummaryInformation Manufacturer="!(loc.Company)" Description="!(loc.Description)" Keywords="!(loc.Keywords)" />

<Icon Id="icon.ico" SourceFile="../CastIt/favicon.ico" />
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Property Id="ARPURLINFOABOUT" Value="https://github.com/Wolfteam/CastIt" />

<UI>
<UIRef Id="WixUI_Minimal" />
<ui:WixUI Id="WixUI_Minimal" />
</UI>

<MediaTemplate EmbedCab="yes"/>
<MediaTemplate EmbedCab="yes" />
<MajorUpgrade AllowSameVersionUpgrades="no" DowngradeErrorMessage="!(loc.DowngradeErrorMsg)" />
<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="$(var.ProductUpgradeCode)">
<UpgradeVersion
Minimum="1.0.0.0" Maximum="99.0.0.0"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="no" />
<UpgradeVersion Minimum="1.0.0.0" Maximum="99.0.0.0" Property="PREVIOUSVERSIONSINSTALLED" IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\Assets\License.rtf" />
Expand All @@ -47,5 +28,5 @@
<ComponentGroupRef Id="ServerComponentsGroup" />
<ComponentGroupRef Id="ServerAutoGeneratedComponentsGroup" />
</Feature>
</Product>
</Package>
</Wix>
47 changes: 8 additions & 39 deletions CastIt.Server.Setup/ServerComponents.wxs
Original file line number Diff line number Diff line change
@@ -1,56 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension">
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:fire="http://wixtoolset.org/schemas/v4/wxs/firewall">
<Fragment>
<ComponentGroup Id="ServerComponentsGroup" Directory="ServerInstallFolder">
<!--StartMenu Shortcut to the desktop app-->
<Component Id="ServerStartMenuShortcutComponent" Guid="{A5AC1F22-CF4A-47F2-B382-47E6AA19701B}">
<Shortcut
Id="ServerStartMenuShortcut"
Name="!(loc.FullProductName)"
Target="[ServerInstallFolder]/TrayIcon/CastIt.Server.Windows.TrayIcon.exe"
Directory="InstallMenuFolder"
WorkingDirectory="ServerInstallFolder"
Icon="icon.ico"/>
<Shortcut Id="ServerStartMenuShortcut" Name="!(loc.FullProductName)" Target="[ServerInstallFolder]/TrayIcon/CastIt.Server.Windows.TrayIcon.exe" Directory="InstallMenuFolder" WorkingDirectory="ServerInstallFolder" Icon="icon.ico" />

<!--Since we are using a shortcut, we need to define an associated key-->
<RegistryValue Id="RegStartMenuShortcutKey" Root="HKCU" Key="SOFTWARE\!(loc.FullProductName)" Name="Shorcut" Value="1" Type="integer" KeyPath="yes"/>
<RegistryValue Id="RegStartMenuShortcutKey" Root="HKCU" Key="SOFTWARE\!(loc.FullProductName)" Name="Shorcut" Value="1" Type="integer" KeyPath="yes" />

<!--We need to always remove the start menu shortcut-->
<RemoveFolder Id="RemoveStartMenu" Directory="InstallMenuFolder" On="uninstall"/>
<RemoveFolder Id="RemoveStartMenu" Directory="InstallMenuFolder" On="uninstall" />
</Component>

<!--Server specific-->
<Component Id="ServerService" Guid="{3C496109-8603-4AF6-921D-5DE146760E7F}">
<File Id="CastItServerExe"
Name="CastIt.Server.exe"
Source="Publish/CastIt.Server.exe"
KeyPath="yes"
Vital="yes" >
<fire:FirewallException Id="FirewallExceptionCastItServerTCP_All"
Name="CastIt.Server"
Protocol="tcp"
Scope="any"
IgnoreFailure="no"
Profile="all"
Description="Exception required so that the chromecast can access the server"/>
<File Id="CastItServerExe" Name="CastIt.Server.exe" Source="Publish/CastIt.Server.exe" KeyPath="yes" Vital="yes">
<fire:FirewallException Id="FirewallExceptionCastItServerTCP_All" Name="CastIt.Server" Protocol="tcp" Scope="any" IgnoreFailure="no" Profile="all" Description="Exception required so that the chromecast can access the server" />
</File>
<ServiceInstall Id="CastItServerService"
Name="CastIt.Server"
DisplayName="CastIt.Server"
Description="The CastIt Server"
Account="LocalSystem"
Start="auto"
Type="ownProcess"
Vital="yes"
ErrorControl="normal"
Interactive="no" />
<ServiceInstall Id="CastItServerService" Name="CastIt.Server" DisplayName="CastIt.Server" Description="The CastIt Server" Account="LocalSystem" Start="auto" Type="ownProcess" Vital="yes" ErrorControl="normal" Interactive="no" />

<ServiceControl Id="StartService"
Name="CastIt.Server"
Wait="yes"
Start="install"
Stop="both"
Remove="uninstall" />
<ServiceControl Id="StartService" Name="CastIt.Server" Wait="yes" Start="install" Stop="both" Remove="uninstall" />
</Component>
</ComponentGroup>
</Fragment>
Expand Down

0 comments on commit 093c546

Please sign in to comment.