Asp.Net 5:如何从project.json文件中加载程序集版本?

Asp.Net 5: How to load assembly version from project.json file?

我的 project.json 文件的版本指定为

{
    "version": "1.0.0-*"
}

如何在代码中读取它?

Get the AssemblyInformationalVersionAttribute from the assembly

  • 在您的 project.json 中更改 "version": "1.1.xxxx"
  • 然后在您的剃刀视图中,也许是 _Layout 页脚? @使用 System.Reflection @{ ViewData["Version"] = typeof(Startup).GetTypeInfo().Assembly.GetCustomAttribute().InformationalVersion; }
  • 然后是 ViewData["Version"]