Automatically increase and sync version for product and bootloader

I'm trying to implement automatic version control so that when creating my Bootstrapper, both versions of MyApp and Bootstrapper will automatically increase and synchronize. Otherwise, you will get duplicate boot records in add / remove programs for each installation attempt with the corresponding versions.

When I create a bootstrapper, the AfterBuild target uses GetAssemblyIdentity to get the automatically generated version of MyApp successfully, and the output file of the boot file is correctly named with an extension version number, for example. MyApp.1.0.5123.1352.exe

But, when I install this Bootstrapper, the version that appears in add / remove programs is always 1.0.0.0 .

I tried using the bindings in the Bootstrapper Bundle Version field, but I cannot get it to read the MyApp version.

Using !(bind.packageVersion.MyApp) causes it to never increase by 1.0.0.0.
Using !(bind.assemblyName.MyApp) leads to build errors (unresolved bind-time variable).
Using !(bind.FileVersion.filAAF013CA9B89B07C81031AE69884BF11) leads to build errors (unresolved bind variable). <- it makes sense because FileID exists in the Setup project, and this is the Bootstrapper project.

What can I do to make my Bootstrapper Bundle package have the same version as MyApp it packs?

===== 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)" 
+6
source share
2 answers

Got! I did not know that you could declare aka DefineConstants variables in BeforeBuild Target.

Below is an example of BeforeBuild Target that generates the BuildVersion variable

Bundle.wxs:

 <Bundle Name="$(var.ProductName) Bootstrapper v$(var.BuildVersion)" Version="$(var.BuildVersion)" 

Bootstrapper.wixproj:

  <Target Name="BeforeBuild"> <GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe"> <Output TaskParameter="Assemblies" ItemName="AssemblyVersion" /> </GetAssemblyIdentity> <PropertyGroup> <DefineConstants>BuildVersion=%(AssemblyVersion.Version)</DefineConstants> </PropertyGroup> </Target> <!-- This is extra, not needed: Renames output file with version number --> <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> 
+6
source

This is what I would do:

  • In my assembly, I use automatic version control: AssemblyVersion("1.0.*")

  • In the project of the installation project, the version using assembly binding !(bind.fileVersion.MyAssembly.dll) (MyAssembly.dll is the file / @ assembly identifier)

  • Complete with binding to the installation version !(bind.packageVersion.Setup) (Setup is the name of the project, as specified in the bundle project.)
+18
source

Source: https://habr.com/ru/post/954636/


All Articles