How to show the dotnet new template version, with which a project was created?

I am creating a custom template for dotnet new. I expect it to be updated as the time goes. I am looking for a way that the projects, built with that template, containg the version of the template itself.

My current approach is:

  • In the pipeline building the template NuGet create a (pre-existing in the solution as Content) JSON file with the version string (known to the pipeline). The version is also stamped into the NuGet, of course, and the DLLs inside it, but this is not currently used.
  • In the generated project have a method, reading and parsing that JSON file. I use ConfigurationBuidler.AddJsonFile for this.

I wonder whether there is a more standard / straightforward way for doing what I want. Possibly using the NuGet or DLL versions instead of that custom-made JSON file.