Getting yak semantic version during runtime

I’m trying to get the semantic version of my plugin during runtime.
I’m defining the version in the .csproj as follows:

<Project Sdk="Microsoft.NET.Sdk">	

When I run yak spec the above version is correctly shown in the created manifest file.
However, I haven’t been able to get the version in code.
From what I’ve gathered the Version tag in .csproj files should be equivalent to the AssemblyInformationalVersionAttribute but when I try to read that:


the GetEntryAssembly() method returns null

I have also tried getting the version through the Plugin.Version property but that returns and not the desired 1.0.0-alpha

I think you want GetExecutingAssemly() instead of GetEntryAssembly().

You could also try System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).ProductVersion.

1 Like

did the trick!

1 Like