-
I've been using MinVer in my cake scripts to generate versioned nuget packages. It works successfully. Now I need the version of my console programme at runtime. I tried: Assembly.GetEntryAssembly().GetName().Version.ToString() // 0.0.0.0
Assembly.GetExecutingAssembly().GetName().Version.ToString() // 0.0.0.0
typeof(Program).GetTypeInfo().Assembly.GetName().Version.ToString() // 0.0.0.0 In all cases I get My config includes this: <PackageReference Include="MinVer" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime;build;native;contentfiles;analyzers</IncludeAssets>
</PackageReference> Can someone spot my mistake? Thank you. (I did read the docs, but couldn't find something applicable to my use case.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The README states that The public static string GetVersion(this Assembly assembly) =>
assembly.GetCustomAttributes(false).OfType<AssemblyInformationalVersionAttribute>().FirstOrDefault()
?.InformationalVersion ?? "Unknown"; |
Beta Was this translation helpful? Give feedback.
The README states that
AssemblyVersion
is set to{MinVerMajor}.0.0.0
, so if you are in the 0.x version range,AssemblyVersion
will be0.0.0.0
.The
Version
.NET SDK property, however, is propagated toAssemblyInformationalVersion
, so you can use that. For example: