Similar Answer: File of a new component isn't installed because there was an old component with the same file
Companion Files: How to use Companion Files in WiX - just a snippet (after debugging it was discovered that OP had an issue of needing to downgrade files instead of a problem with number of version digits - very common issue):
<..>
<Component Id="MyFile.exe" Feature="Main">
<File Id="MyFile.exe" Source="MyFile.exe"></File>
</Component>
<Component Id="MyFile_2.exe" Guid="{0EBDFD64-017B-428F-BB67-3D82EA2A99AF}" Feature="Main">
<File Source="MyFile_2.exe" CompanionFile="MyFile.exe"></File>
</Component>
<..>
One-Line Summary: In the second component we point to the first component's file so that MyFile_2.exe will install whenever MyFile.exe is installed - regardless of versioning issues.
Older answer below left in for reference and the WiX source that can be used for testing.
MSI Version: Windows installer only cares about the first three numbers when checking version number.
File Version vs ProductVersion: The above statement is generally correct, but to the best of my knowledge (and based on a quick smoke test), this 3-digit restriction only applies to the MSI's ProductVersion
(the version of the MSI itself), and not to actual file version numbers
.
File versions are respected in 4 digits, as opposed to the 3 digit
limit for the MSI's ProductVersion
(the version for the MSI
itself). Please run a test yourself to be sure. Sample WiX markup to do so below.
REINSTALLMODE: The file-overwrite modifier mechanism REINSTALLMODE can be used to force overwrite files regardless of version. This mechanism must not be used since it can cause a number of problems: unnecessary reboot prompts, downgrading of system shared files, cause some files to be upgraded and others not (old and new packages installed out of sequence), in earlier versions of Windows crashes as protected files are attempted downgraded, etc...
WiX Mockup Test Source: I'll dump a simple test WiX source here to help you test this quickly (on different OS versions for example, I tested on Windows 10):
Incidentally, due to some inherent design characteristics of this
sample, it will also illustrate that major upgrades fail when you only
bump up the last digit of the 4-digit version number, but file
overwrites will work. When you install version 2, you will find two product entries in Add / Remove Programs. This is expected based on the design of the sample. Just uninstall both.
<?define MyVersion = "1.0.0.0" ?>
<?define MyReleasePath = "$(sys.SOURCEFILEDIR)_Files$(var.MyVersion)" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="FileVersioning" Language="1033" Version="$(var.MyVersion)"
Manufacturer="FileVersioning" UpgradeCode="{4864AA4A-EA1D-4367-8427-85D296B0A2A6}">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="Main" Title="FileVersioning" Level="1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FileVersioning">
<Component Feature="Main">
<File Source="$(var.MyReleasePath)MyTestFile.exe"></File>
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
Usage:
- Create WiX project, replace template content with above markup.
- Make a sub-folder in WiX project folder called
_Files
and two further sub folders under there with two versions of the same file as illustrated below.
- Quick Way: In Visual Studio, right click the WiX project and select
Open Folder in File Explorer
to get to the WiX project folder quickly.
- Now paste in two folders or create them.
- You can open the EXE in Visual Studio to "hack" the version number so you use the same EXE or DLL in both folders with different version numbers. See section below for information.
- Change MyVersion define to the version number you want to build. For example:
<?define MyVersion = "23.4.5.2" ?>
. This also affects where the sample expects the source file to be located on disk.
- Update the file name in the File element to match the name of your versioned file (
<File Source="$(var.MyReleasePath)MyTestFile.exe"></File>
).
- Compile setup, install it, inspect version number for installed file.
- Change the WiX version and compile the next setup (
<?define MyVersion = "23.4.5.3" ?>
).
- Install on top of existing install. Check that the new version of the file has been installed.
Folder structure for versioned files (create inside main project folder):
_Files
23.4.5.2MyTestFile.exe
23.4.5.3MyTestFile.exe
Open EXE as Resource: In Visual Studio try this:
File
=> Open
=> File
- Browse for a versioned file (
EXE
, DLL
, etc...
)
- Click versioned file once (and only once)
- Click the down arrow for the
Open
button => Open With...
- Select
Resource Editor
and open file.
- Locate
Version section
, open and double click entry.
- Change version numbers, save new file version (not on top of existing).
Links: