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.
When I build the bootstrapper, an AfterBuild target uses GetAssemblyIdentity
to get the automatically generated version of MyApp successfully, and the bootstrapper output file is properly named with the incremented version number e.g. MyApp.1.0.5123.1352.exe
But, when I install this Bootstrapper, the version that shows in add/remove programs is always 1.0.0.0
.
I've tried using bindings in the Bootstrapper Bundle Version field but I can't get it to read the MyApp version.
Using !(bind.packageVersion.MyApp)
results in never incrementing 1.0.0.0.
Using !(bind.assemblyName.MyApp)
results in build errors (Unresolved bind-time variable).
Using !(bind.FileVersion.filAAF013CA9B89B07C81031AE69884BF11)
results in build errors (Unresolved bind-time variable). <-- Makes sense as the FileID exists in the Setup
project, and this is the Bootstrapper
project.
What can I do to get my Bootstrapper Bundle to have the same version as the MyApp it is packaging?
=====MyApp\AssemblyInfo.cs=====
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
=====Setup.wixproj=====
<Target Name="BeforeBuild">
<PropertyGroup>
<LinkerBaseInputPaths>..\MyApp\bin\$(Configuration)\</LinkerBaseInputPaths>
</PropertyGroup>
<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'" />
</Target>
=====Bootstrapper.wixproj=====
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).exe" DestinationFiles=".\bin\$(Configuration)\MyApp.%(AssemblyVersion.Version).exe" />
<Delete Files=".\bin\$(Configuration)\$(OutputName).exe" />
</Target>
=====Bootstrapper\Bundle.wxs=====
<Bundle Name="$(var.ProductName) Bootstrapper v!(bind.packageVersion.MyApp)"
Version="!(bind.packageVersion.MyApp)"