Skip to content

Commit

Permalink
[CLI.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 20147bf commit dbf01b8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 115 deletions.
79 changes: 19 additions & 60 deletions CastIt.Cli.Setup/CastIt.Cli.Setup.wixproj
Original file line number Diff line number Diff line change
@@ -1,88 +1,47 @@
<?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>c8841eb1-e5ae-44d2-b05e-aeca86542e94</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CastItCliSetup-$(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>
<ItemGroup>
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Heat" Version="4.0.4" />
</ItemGroup>
<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="CliAutoGeneratedComponents.wxs" />
<Compile Include="CliComponents.wxs" />
<Compile Include="Directories.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</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);CliBasePath=Publish</DefineConstants>
</PropertyGroup>
</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.Cli\bin\">
</Exec>
<Exec Command="if exist Publish rd /s /q Publish"></Exec>
<Exec Command="rd /s /q ..\CastIt.Cli\bin\"></Exec>
<!--Then, we publish our apps-->
<Exec Condition="$(Configuration) != 'Debug'" Command="dotnet publish ../CastIt.Cli/CastIt.Cli.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.Cli/CastIt.Cli.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish">
</Exec>
<!--Here we get the assembly versions-->
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Cli\bin\$(Configuration)\net6.0\win-$(Platform)\CastIt.dll">
<Exec Command="dotnet publish ../CastIt.Cli/CastIt.Cli.csproj -c $(Configuration) -r win-$(Platform) --self-contained -p:PublishSingleFile=true -o Publish"></Exec>
<!--Here we get the assembly versions-->
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Cli\bin\$(Configuration)\net8.0\win-$(Platform)\CastIt.dll">
<Output TaskParameter="Assemblies" ItemName="CliAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>$(DefineConstants);InstallerVersion=%(CliAssembly.Version)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);InstallerVersion=%(CliAssembly.Version)</DefineConstants>
</PropertyGroup>
<!--Finally we pick up all the files that we want to publish, and create an autogenerated component-->
<HeatDirectory OutputFile="CliAutoGeneratedComponents.wxs" DirectoryRefId="CliInstallFolder" ComponentGroupName="CliAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.CliBasePath" RunAsSeparateProcess="true"/>
<HeatDirectory OutputFile="CliAutoGeneratedComponents.wxs" DirectoryRefId="CliInstallFolder" ComponentGroupName="CliAutoGeneratedComponentsGroup" SuppressCom="true" Directory="Publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.CliBasePath" />
</Target>
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Cli\bin\$(Configuration)\net6.0\win-$(Platform)\CastIt.dll">
<GetAssemblyIdentity AssemblyFiles="..\CastIt.Cli\bin\$(Configuration)\net8.0\win-$(Platform)\CastIt.dll">
<Output TaskParameter="Assemblies" ItemName="CliAssembly" />
</GetAssemblyIdentity>
<Exec Command="if not exist Installers mkdir Installers" />
Expand Down
3 changes: 1 addition & 2 deletions CastIt.Cli.Setup/CliComponents.wxs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?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="CliComponentsGroup" Directory="CliInstallFolder">
<!--First we create a system variable-->
Expand Down
15 changes: 6 additions & 9 deletions CastIt.Cli.Setup/Directories.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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">
Expand All @@ -12,19 +10,18 @@

<!--If 64 bits-->
<?if $(var.Platform)=x64?>
<Directory Id="ProgramFiles64Folder">
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="CliInstallFolder" Name="Cli" />
</Directory>
</Directory>
</StandardDirectory>
<!--Else 32 bits-->
<?else?>
<Directory Id="ProgramFilesFolder">
<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)">
<Directory Id="CliInstallFolder" Name="Cli" />
</Directory>
</Directory>
</StandardDirectory>
<?endif?>
</Directory>
</Fragment>
</Fragment>
</Wix>
25 changes: 12 additions & 13 deletions CastIt.Cli.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.Cli (32 bits)</String>
<String Id="ProductName_x64">CastIt.Cli (64 bits)</String>
<String Id="Company">MiraiSoft</String>
<String Id="Description">The CastIt CLI</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="ProductName_x86" Value="CastIt.Cli (32 bits)" />
<String Id="ProductName_x64" Value="CastIt.Cli (64 bits)" />
<String Id="Company" Value="MiraiSoft" />
<String Id="Description" Value="The CastIt CLI" />
<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 is already installed.</String>
<String Id="DowngradeErrorMsg" Value="A newer version of CastIt is already installed." />
</WixLocalization>
43 changes: 12 additions & 31 deletions CastIt.Cli.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 = "{ba8f6881-93dc-4255-8c79-46cd8af78945}" ?>

<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 @@ -48,5 +29,5 @@
<ComponentGroupRef Id="CliComponentsGroup" />
<ComponentGroupRef Id="CliAutoGeneratedComponentsGroup" />
</Feature>
</Product>
</Package>
</Wix>

0 comments on commit dbf01b8

Please sign in to comment.