4

I have a solution with Asp.NET Core project, and a WiX Project that generates an MSI to deploy it to an IIS Server.

Currently whenever we build the project we have to update build numbers in the following locations:

  1. Asp.NET Project Properties Page > Package Tab > Package version: x.x.x
  2. Asp.NET Project Properties Page > Package Tab > Assembly version: x.x.x.x
  3. Asp.NET Project Properties Page > Package Tab > Assembly file version: x.x.x.x
  4. WiX wxs file:

I want to minimize the number of individual edits required to update the version. Ideally I'd only like to have to set versions on Asp.NET Project Properties Page, and Wix automatically reflect the change.

Based on related answers I was able to get the WiX version to get set automatically by binding it to the AssemblyFileVersion. However there are two issues with that solution. You end up with 4 digit version number for MSI, and god knows what will end up choking on that in the future. Another issue is that I don't want to tie my MSI version to dll version (there may be a case where the package is updated by dll is not).

That's why I'm looking for a way to automatically set WiX version to the package version from Asp.NET properties page. It solves the two issues above, as that version number can be set to 3 digits, and it is also not tied to dll file versions. How do I go about it? The package version is stored inside Asp.NET csproj file as following (it's the 1.0.2 tag):

  <PropertyGroup>
    ...
    <Version>1.0.2</Version>
    <AssemblyVersion>1.0.0.2</AssemblyVersion>        
    <FileVersion>1.0.0.2</FileVersion>
    <Company>My Company</Company>
    <Product>My Product</Product>
    <Authors>My Company</Authors>
  </PropertyGroup>

How can I set attribute inside wxs project file to that value during build? I'll even go with hack solutions at this point, because it doesn't look like there's a standard way of doing it.

enter image description here

Eternal21
  • 4,190
  • 2
  • 48
  • 63
  • 1
    Not my expertise, but a quick look. Using an environment variable seems to work, but updates to the variable are not picked up without a Visual Studio restart. Not good. Terrible in fact? In WiX I used: `$(env.MyVersion)`. In the ASPCore project I used: `$(MyVersion)` where `MyVersion` is a user-environment variable. Likely a tested and rejected approach already? [Couldn't get this to work properly](https://stackoverflow.com/a/13251359/129130). I am not experienced with this, maybe have a quick read. – Stein Åsmul Oct 13 '18 at 02:23
  • I would recommend setting up a DevOps pipeline system and use that to apply the version number to your code and to your installer. I use a semantic version number compatible with WiX/MSI (0-255.0-65535.0-65535) and tack on a .0 where needed for Windows version resources. – Christopher Painter Oct 13 '18 at 12:51

1 Answers1

-1

I ended up writing a Powershell script that uses regex to scan relevant files for lines with versions in them and replaces the text with the new version. It's a simple solution that ends up working for all types of project files (AssemblyInfo.cs, Product.wxs, .vdproj, .csproj, package.json, .aip, etc.), since all you're doing is manipulating text files. To figure out which lines you want to replace, just modify the version using UI and check the change history using git for example.

Eternal21
  • 4,190
  • 2
  • 48
  • 63