I am trying to create an installer that gets built each time the solution gets built and creates a MSI within the solution build output folder. The install is just for installing the components of the soution \bin folder. We use the Major.Minor.Patch.Build version schema using the Wintellect TFS Build Number Task.
I want each MSI to be able to be installed without uninstalling the previous one. Each install will install into its specific \bin_x.x.x.x folder and create a specific desktop shortcut and menu entry with app x.x.x.x description. It should be able to detect if the MSI you are trying to install has already been instead and prompt for repair or uninstall.
<?define ProductVersion=!(bind.FileVersion.$(var.MyProject.TargetFileName)) ?>
<?define ProductName=MyProduct !(bind.FileVersion.$(var.MyProject.TargetFileName)) ?>
<Product Id="*" Name="$(var.ProductName)" Version="$(var.ProductVersion)" UpgradeCode="$(var.NewUpgradeCode)">
<MajorUpgrade AllowSameVersionUpgrades="yes" AllowDowngrades="no" MigrateFeatures="no" Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
In the Directory definition I use the var.ProductVersion to define the \bin_x.x.x.x folder
<Directory Id="BINFOLDER" Name="bin_$(var.ProductVersion)"/>
In the project file I define the NewUpgradeCode
<PropertyGroup>
<NewUpgradeCode>$([System.Guid]::NewGuid())</NewUpgradeCode>
<DefineConstants>NewUpgradeCode=$(NewUpgradeCode)</DefineConstants>
</PropertyGroup>
I use a HeatDirectory entry in the project file to get a list of files in the output bin folder to install.
<HeatDirectory OutputFile="BinFiles.wxs" Directory="..\Build\x64\Release\" ToolPath="$(WixToolPath)" PreprocessorVariable="var.MyProject.TargetDir" DirectoryRefId="BINFOLDER" ComponentGroupName="BinFolderComponents" GenerateGuidsNow="true" SuppressFragments="true" SuppressCom="true" SuppressRegistry="true" SuppressRootDirectory="true" KeepEmptyDirectories="true">
This is all working very well with a few minor issues.
The current Upgrade scheme is still removing the previous installed version regardless of the version number. I want version 1.0.0.1 and 1.0.0.2 to both be installed at the same time. The way I have it configured above it seems to keep uninstalling the last version I installed?
I'd like to name the MSI file MyProject_x.x.x.x.MSI. But no matter what approach I take to name the MSI file I always get 0 for the Build number.
Even if the version of the EXE is something like 1.2.0.321 It always returns 1.2.0.0
But the bind.FileVersion does extract the full version of the EXE? But that is only available in the Product.XML not in the Project file where the MSI filename is defined?
I want to delete the Name_x.x.x.x.msi from the output folder before running the HeatDirectory file harvest so it is not include. But since I don't know the previous version number I would need to do a wildcard delete *.msi during the BeforeBuild process. If I do the delete as a Pre-Build event it doesn't delete the file(s) until after the HeatDirectory is run in the BeforeBuild Target.
The wildcard delete doesn't work in this XML markup above. So how do I make sure there are no .MSI files in my output before running HeatDirectory?