Skip to content

Commit

Permalink
[CastIt.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 093c546 commit 92dadcf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 137 deletions.
70 changes: 13 additions & 57 deletions CastIt.Setup/CastIt.Setup.wixproj
Original file line number Diff line number Diff line change
@@ -1,79 +1,35 @@
<?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>caee4ecb-1448-4468-9776-01f5feb188be</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CastItSetup-$(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.3</InstallerVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="DesktopAutoGeneratedComponents.wxs" />
<Compile Include="DesktopComponents.wxs" />
<Compile Include="Directories.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization.wxl" />
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Heat" Version="4.0.4" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUtilExtension">
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
<Name>WixUtilExtension</Name>
</WixExtension>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</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.
-->
<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\bin\">
</Exec>
<Exec Command="if exist Publish rd /s /q Publish"></Exec>
<Exec Command="rd /s /q ..\CastIt\bin\"></Exec>
<!--Then, we publish our apps-->
<Exec Condition="$(Configuration) != 'Debug'" Command="dotnet publish ../CastIt/CastIt.csproj -c $(Configuration) -r win-$(Platform) --self-contained -o Publish">
</Exec>
<Exec Condition="$(Configuration) == 'Debug'" Command="dotnet publish ../CastIt/CastIt.csproj -c $(Configuration) -r win-$(Platform) --self-contained -o Publish">
</Exec>
<Exec Command="dotnet publish ../CastIt/CastIt.csproj -c $(Configuration) -r win-$(Platform) --self-contained -o Publish"></Exec>
<!--Here we get the assemblies versions-->
<GetAssemblyIdentity AssemblyFiles="..\CastIt\bin\$(Configuration)\net6.0-windows\win-$(Platform)\CastIt.dll">
<GetAssemblyIdentity AssemblyFiles="..\CastIt\bin\$(Configuration)\net8.0-windows\win-$(Platform)\CastIt.dll">
<Output TaskParameter="Assemblies" ItemName="DesktopAssembly" />
</GetAssemblyIdentity>
<!--And asign it to a variable-->
Expand All @@ -87,10 +43,10 @@
<DefineConstants>$(DefineConstants);InstallerVersion=%(DesktopAssembly.Version)</DefineConstants>
</PropertyGroup>
<!--Finally we pick up all the files that we want to publish, and create an autogenerated component-->
<HeatDirectory OutputFile="DesktopAutoGeneratedComponents.wxs" DirectoryRefId="DesktopInstallFolder" ComponentGroupName="DesktopAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.DesktopBasePath" RunAsSeparateProcess="true"/>
<HeatDirectory OutputFile="DesktopAutoGeneratedComponents.wxs" DirectoryRefId="DesktopInstallFolder" ComponentGroupName="DesktopAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.DesktopBasePath" />
</Target>
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\CastIt\bin\$(Configuration)\net6.0-windows\win-$(Platform)\CastIt.dll">
<GetAssemblyIdentity AssemblyFiles="..\CastIt\bin\$(Configuration)\net8.0-windows\win-$(Platform)\CastIt.dll">
<Output TaskParameter="Assemblies" ItemName="DesktopAssembly" />
</GetAssemblyIdentity>
<Exec Command="if not exist Installers mkdir Installers" />
Expand Down
27 changes: 7 additions & 20 deletions CastIt.Setup/DesktopComponents.wxs
Original file line number Diff line number Diff line change
@@ -1,37 +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>
<ComponentGroup Id="DesktopComponentsGroup" Directory="DesktopInstallFolder">
<!--StartMenu Shorcut to the desktop app-->
<Component Id="DesktopStartMenuShorcutComponent" Guid="{785BA406-F1E4-4DC3-8516-9B90A47EF835}">

<Shortcut
Id="DesktopStartMenuShorcut"
Name="!(loc.ProductName)"
Target="[DesktopInstallFolder]CastIt.exe"
Directory="InstallMenuFolder"
WorkingDirectory="DesktopInstallFolder"
Icon="icon.ico"/>
<Shortcut Id="DesktopStartMenuShorcut" Name="!(loc.ProductName)" Target="[DesktopInstallFolder]CastIt.exe" Directory="InstallMenuFolder" WorkingDirectory="DesktopInstallFolder" Icon="icon.ico" />

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

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

<!--Desktop Shorcut to the desktop app-->
<Component Id="DesktopShorcutComponent" Guid="{402D3F84-680F-468E-996C-FA2FDC711F7B}">
<Shortcut
Id="DesktopShorcut"
Name="!(loc.ProductName)"
Target="[DesktopInstallFolder]CastIt.exe"
Directory="DesktopFolder"
WorkingDirectory='DesktopInstallFolder'
Icon="icon.ico"/>
<Shortcut Id="DesktopShorcut" Name="!(loc.ProductName)" Target="[DesktopInstallFolder]CastIt.exe" Directory="DesktopFolder" WorkingDirectory="DesktopInstallFolder" Icon="icon.ico" />

<RegistryValue Id="RegShorcutKey" Root="HKCU" Key="SOFTWARE\!(loc.ProductName)" Name="Shorcut" Value="1" Type="integer" KeyPath="yes"/>
<RemoveFolder Id="RemoveShorcut" Directory="DesktopInstallFolder" On="uninstall"/>
<RegistryValue Id="RegShorcutKey" Root="HKCU" Key="SOFTWARE\!(loc.ProductName)" Name="Shorcut" Value="1" Type="integer" KeyPath="yes" />
<RemoveFolder Id="RemoveShorcut" Directory="DesktopInstallFolder" On="uninstall" />
</Component>
</ComponentGroup>
</Fragment>
Expand Down
23 changes: 10 additions & 13 deletions CastIt.Setup/Directories.wxs
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<?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>

<Directory Id="DesktopFolder" Name="Desktop"/>
<StandardDirectory Id="DesktopFolder" />

<!--If 64 bits-->
<?if $(var.Platform)=x64?>
<Directory Id="ProgramFiles64Folder">
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="DesktopInstallFolder" Name="Desktop" />
</Directory>
</Directory>
</StandardDirectory>
<!--Else 32 bits-->
<?else?>
<Directory Id="ProgramFilesFolder">
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="DesktopInstallFolder" Name="Desktop" />
</Directory>
</Directory>
</StandardDirectory>
<?endif?>
</Directory>
</Fragment>
</Fragment>
</Wix>
25 changes: 12 additions & 13 deletions CastIt.Setup/Localization.wxl
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?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="ProductName_x86">CastIt (32 bits)</String>
<String Id="ProductName_x64">CastIt (64 bits)</String>
<String Id="Company">MiraiSoft</String>
<String Id="Description">An app to cast your files in a simple way</String>
<String Id="Comments">Made with love</String>
<String Id="Keywords">Desktop, .Net Core</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="ProductName_x86" Value="CastIt (32 bits)" />
<String Id="ProductName_x64" Value="CastIt (64 bits)" />
<String Id="Company" Value="MiraiSoft" />
<String Id="Description" Value="An app to cast your files in a simple way" />
<String Id="Comments" Value="Made with love" />
<String Id="Keywords" Value="Desktop, .Net Core" />
<String Id="Languages" Value="1033" />
<String Id="Ok" Value="Ok" />
<String Id="Launch" Value="Launch" />

<String Id="DowngradeErrorMsg">A newer version of CastIt is already installed.</String>
<String Id="DowngradeErrorMsg" Value="A newer version of CastIt is already installed." />
</WixLocalization>
46 changes: 12 additions & 34 deletions CastIt.Setup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,53 +1,31 @@
<?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 = "{DD46D441-3F63-416F-A2A2-9785B668C4E0}" ?>

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

<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)"/>
<SummaryInformation Manufacturer="!(loc.Company)" Description="!(loc.Description)" Keywords="!(loc.Keywords)" />

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

<!--Launch after install-->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.Launch)" />
<Property Id="WixShellExecTarget" Value="[DesktopInstallFolder]CastIt.exe" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<CustomAction Id="LaunchApplication" DllEntry="WixShellExec" Impersonate="yes" BinaryRef="Wix4UtilCA_X86" />

<UI>
<UIRef Id="WixUI_Minimal" />
<ui:WixUI Id="WixUI_Minimal" />
<!--This publish is required to make the 'launch after install' work-->
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication" Condition="WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed" />
</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>


Expand All @@ -60,5 +38,5 @@
<ComponentGroupRef Id="DesktopComponentsGroup" />
<ComponentGroupRef Id="DesktopAutoGeneratedComponentsGroup" />
</Feature>
</Product>
</Package>
</Wix>

0 comments on commit 92dadcf

Please sign in to comment.