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

こ雲淡風輕ζ 提交于 2019-12-08 16:24:31

问题


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"]


来源:https://stackoverflow.com/questions/32826684/asp-net-5-how-to-load-assembly-version-from-project-json-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!