Display project version in ASP.NET MVC Core application (RC2)

前端 未结 5 617
生来不讨喜
生来不讨喜 2020-12-11 00:41

How do I display application version from the project.json? I am using gulp-bump to autoincrement version, but I can\'t show the recent version. Here is what I\

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 01:06

    I used a different approach, as stated in this answer which gave me a SemVer version (1.0.0) which is actually in my project.json and not 1.0.0.0, which is returned by accepted answer. So the code would be:

    var runtimeVersion = typeof(Startup)
                .GetTypeInfo()
                .Assembly
                .GetCustomAttribute()
                .InformationalVersion;
    

    It returns correct suffixed versions as well, i.e. something like "2.0.1-dev01"

提交回复
热议问题