Version number of CSProj and TapPackage files

Hello everyone,

I have a question regarding versioning. I have a solution that holds several projects. Each project outputs a DLL/Exe, where I want to track the version number. After I am finished with the development I want to create a .TapPackage that has the same version as the DLL file. Currently I have to update the version in the .csproj and package.xml. Is there an elegant way to solve this within a single file?

I tried “Directory.Build.props” which works for .csproj but not for the package.xml.

2 Likes

@david.minker we use a .gitversion file for this and the $(GitVersion) macro:

1 Like

Bumping this because I think I’m trudging down the same path at the moment…

I just want to confirm that for building a TapPackage there isn’t any way to set the version as a command line argument or via an environment/build variable? GitVersion or manually setting it are the only options?

I’m just wondering if there is any existing option a bit more CI friendly than manually editing the package.xml file for us poor souls that work places that use a different VCS.

Hi @Jim_B,

I’m curious to know which VCS you are using instead maybe we can add versioning support for that eventually. Or maybe add some hooks so that it can be a plugin.

Anyway, there is definitely a way you can control this from one place without using git + the {GitVersion} macro.

The package.xml file system supports expanding based on environment variables as well. So if you set BUILD_VERSION=1.2.3 and in your package.xml file set:

<Package Name="VersioningTest" xmlns="http://opentap.io/schemas/package" InfoLink="" Version="$(BUILD_VERSION)" OS="Windows,Linux">
 <Variables>
    <!-- optionally set fallback version in case the environment variable is not set. -->
    <BUILD_VERSION Condition="$(BUILD_VERSION) == ''">0.0.1</BUILD_VERSION>
  </Variables>

And in your Directory.build.probs set:

<PropertyGroup Condition="'$(BUILD_VERSION)' == ''">
           <!-- fallback to 0.0.1 or whatever -->
            <BUILD_VERSION>0.0.1</BUILD_VERSION>
    </PropertyGroup>
        
    <PropertyGroup>
        <AssemblyVersion>$(BUILD_VERSION)</AssemblyVersion>
        <FileVersion>$(BUILD_VERSION)</FileVersion>
        <Version>$(BUILD_VERSION)</Version>
        <OpenTapVersion>9.21.1</OpenTapVersion>
        <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
        <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
        <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
        <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
        <OutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</OutputPath>
    </PropertyGroup>

Now if I set BUILD_VERSION to 1.2.3, I get a file named VersioningTest.1.2.3.TapPackage and the DLL inside:
image

1 Like

Hi @rolf_madsen , thanks for the response.

We use Perforce.

Direct support or plugin hooks would be great, but for now the method that you have described is working well.

Thank you!