title: Automatically increment and synchronize version for product and bootstrapper
body: <p>I'm trying to implement automatic versioning so that when I build my Bootstrapper, both the MyApp and Bootstrapper versions are automatically incremented and synchronized. Otherwise you end up with duplicate bootstrap entries in the add/remove programs for each installation attempt with matching versions.</p>
  
  <p>When I build the bootstrapper, an AfterBuild target uses <code>GetAssemblyIdentity</code> to get the automatically generated version of MyApp successfully, and the bootstrapper output file is properly named with the incremented version number e.g. <code>MyApp.1.0.5123.1352.exe</code></p>
  
  <p>But, when I install this Bootstrapper, the version that shows in add/remove programs is always <code>1.0.0.0</code>.</p>
  
  <p>I've tried using bindings in the Bootstrapper Bundle Version field but I can't get it to read the MyApp version.</p>
  
  <p>Using <code>!(bind.packageVersion.MyApp)</code> results in never incrementing 1.0.0.0.<br>
  Using <code>!(bind.assemblyName.MyApp)</code> results in build errors (Unresolved bind-time variable).<br>
  Using <code>!(bind.FileVersion.filAAF013CA9B89B07C81031AE69884BF11)</code> results in build errors (Unresolved bind-time variable). &lt;-- Makes sense as the FileID exists in the <code>Setup</code> project, and this is the <code>Bootstrapper</code> project.  </p>
  
  <blockquote>
    <p>What can I do to get my Bootstrapper Bundle to have the same version
    as the MyApp it is packaging?</p>
  </blockquote>
  
  <p>=====MyApp\AssemblyInfo.cs=====</p>
  
  <pre><code>[assembly: AssemblyVersion("1.0.*")] 
  [assembly: AssemblyFileVersion("1.0.*")] 
  </code></pre>
  
  <p>=====Setup.wixproj=====</p>
  
  <pre><code>&lt;Target Name="BeforeBuild"&gt;
    &lt;PropertyGroup&gt;
      &lt;LinkerBaseInputPaths&gt;..\MyApp\bin\$(Configuration)\&lt;/LinkerBaseInputPaths&gt;
    &lt;/PropertyGroup&gt;
    &lt;HeatDirectory OutputFile="MyApp_Files.wxs" Directory="..\MyApp\bin\$(Configuration)\" DirectoryRefId="INSTALLLOCATION" ComponentGroupName="MyApp_Project" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.PackageThisProject)'=='True'" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>=====Bootstrapper.wixproj=====</p>
  
  <pre><code>&lt;Target Name="AfterBuild"&gt;
      &lt;GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe"&gt;
          &lt;Output TaskParameter="Assemblies" ItemName="AssemblyVersion" /&gt;
      &lt;/GetAssemblyIdentity&gt;
      &lt;Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).exe" DestinationFiles=".\bin\$(Configuration)\MyApp.%(AssemblyVersion.Version).exe" /&gt;
      &lt;Delete Files=".\bin\$(Configuration)\$(OutputName).exe" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>=====Bootstrapper\Bundle.wxs=====</p>
  
  <pre><code>&lt;Bundle Name="$(var.ProductName) Bootstrapper v!(bind.packageVersion.MyApp)" 
          Version="!(bind.packageVersion.MyApp)"
  </code></pre>