WIX: Howto set the name of the msi output file dynamically

Jan picture Jan · Nov 6, 2009 · Viewed 27.5k times · Source

I want to include some dynamic part in the filename of the msi file my wix projects produce. This dynamic part should be controlled by variables which are part of my wix project and are declared like this:

<?define ProductVersion="7.1.0.1" ?>

Does anybody know about a way of sending that value of that wix variable to the linker to use it as a part of the output filename?

By the way: I'm using Wix3

Answer

Charlie picture Charlie · Oct 14, 2012

You could update the OutputName of your .wixproj and use an MSBuild variable to pass through the version number or any other variable you like.

My build script looks like this:

set PRODUCTVERSION=7.1.0.1
MSBuild.exe /p:Configuration=Debug /p:ProductVersion=%PRODUCTVERSION% Installer.wixproj

And my WiX project looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>1.0.0.0</ProductVersion>
    <ProjectGuid>{b7415c44-8d59-4ac2-b698-03e399a305e3}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>Installer.$(ProductVersion)</OutputName>
    ...
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>Debug</DefineConstants>
    <WixVariables>ProductVersion=$(ProductVersion)</WixVariables>
  </PropertyGroup>
  ...
</Project>

The output would be:

Installer.7.1.0.1.msi