Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

{
    "version": "1.0.0-*"
}

How can I read it in code?

like image 470
tmm360 Avatar asked Sep 28 '15 15:09

tmm360


2 Answers

Get the AssemblyInformationalVersionAttribute from the assembly

like image 176
Victor Hurdugaci Avatar answered Nov 13 '22 20:11

Victor Hurdugaci


  • 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"]
like image 1
lant Avatar answered Nov 13 '22 18:11

lant