Octopack: Version number extraction issues

Hi! I have a solution with 100 projects that is build through TeamCity. Each project has very exact information in assemblyversion, and the version differs for the projects in the solution, eg version ranges from 3.0.0 to 3.2.1. Now we use OctoPack to create nuget packages for some of the projects and Octopack will extract the version from AssemblyInfo.cs like the documentation says. The thing is that I would like to build my own version number using the numbers in these files, how can I accomplish that? a parameter on the command line will not do because version is unique for every project. i can make sure there is a file (eg the NuSpec-file) that contains the exact version I want in each project, but Octopack ignores tag when packaging for some reason.

Lets say I want each project to have version Major.Minor.Patch.Build. None of my assemblyinfo-attributes contains that exact string (according to Microsoft documentation, their format is Major.Minor.Build.Revision (why build before revision I cannot understand but anyway). AssemblyInformationalVersion (Product version) cannot beused either because we include prerelease labels in this information and that makes it unsuitable for version extraction.

I need some way to tell Octopack what version to use per project, not per solution. Maybe I could modify the csproj-file so that a version-variable is defined in MsBuild for each project but that seems like a lot of work. My NuSpec-file contains the correct version-string but like I said, this is not picked up by OctoPack.

I think I have a solution now if anyone needs this kind of control: I am not going to post the details cause I gave up on the solution before I finished. But here is the approach:
Use powershell to append a PropertyGroup/OctoPackPackageVersion-element with the desired version number to each .csproj-file that needs to be packaged. I am pretty sure this will Make OctoPack pick up this variable instead of trying to extract it from AssemblyInfo.cs

Hello! Its me again, talking to myself. I had to use my proposed solution anyway and if anyone else if very picky with their version and cannot use one version number for all projects in a solution, this might be something for you. I will try to post this script to GitHub in the near future. Anyway, this approach works.

  1. CI Ectracts version numbers from current assembly (regex parser)
  2. CI invokes Powershell script that inserts OctoPackPackageVersion-variable in each projects that should be packed
  3. CI builds Octopack will pack (and pick up the variable that was inserted, success!

Here is the file: GitHub - update_csproj.ps1

Hi Emil,

Sounds like you got the solution that you needed :slight_smile: Thanks for sharing it on the forum for others to find.

Vanessa