I'm working on a .NET tool which will add a reference to a NuGet package to a project file, very similar to what nbgv does.
For this, I'd like to use a property on ThisAssembly which would return the NuGet package version.
@AArnott what do you think?
It feels a bit odd. An project might not even pack itself, so it wouldn't know the version of its containing package yet with this generated it would believe it does.
I guess I'd accept a PR with this change, but I think I'd want it opt-in via an msbuild property.
Maybe it can be activated by the IsPackable=true property in the project file. That would make it 'right' about 99% of the time.
This sounds something that I could use.
For background: I have a desktop app and want to show the version in the About dialog as e.g. 3.0.0+7f41ecfa0f for a non-public build and just 3.0.0 for a public build
As far as I can see there's currently no way to detect from C# whether the build was a public release or not, is that correct?
@grokys You can already tell if it's a public release since ThisAssembly.IsPublicRelease is a property you can access:
The authoritative list is here:
Hmm, strange - I'm not seeing that:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: System.Reflection.AssemblyVersionAttribute("3.0.0.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("3.0.0.25")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.0.0+1a39aac1e1")]
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[System.CodeDom.Compiler.GeneratedCode("Nerdbank.GitVersioning.Tasks","3.0.25.34678")]
#endif
internal static partial class ThisAssembly {
internal const string AssemblyVersion = "3.0.0.0";
internal const string AssemblyFileVersion = "3.0.0.25";
internal const string AssemblyInformationalVersion = "3.0.0+1a39aac1e1";
internal const string AssemblyName = "ABC";
internal const string AssemblyConfiguration = "Release";
internal const string GitCommitId = "1a39aac1e1cebff7421259e5db45aff3c1061028";
internal static readonly System.DateTime GitCommitDate = new System.DateTime(637255600010000000L, System.DateTimeKind.Utc);
internal const string RootNamespace = "ABC";
}
Oh wait, ignore that. Looks like NuGet wasn't showing me the newer versions of the packages. I can see it now.