Asp.Net 5: How to load assembly version from proje

2019-06-16 10:01发布

问题:

I've the project.json file with a version specified as

{
    "version": "1.0.0-*"
}

How can I read it in code?

回答1:

Get the AssemblyInformationalVersionAttribute from the assembly



回答2:

  • in your project.json change the "version": "1.1.xxxx"
  • then in your razor view, maybe _Layout footer? @using System.Reflection @{ ViewData["Version"] = typeof(Startup).GetTypeInfo().Assembly.GetCustomAttribute().InformationalVersion; }
  • then ViewData["Version"]