问题
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