显示项目版本的ASP.NET MVC核心应用(RC2) [英] Display project version in ASP.NET MVC Core application (RC2)
问题描述
我如何从project.json显示应用程序的版本?
我使用吞掉凸点
来自动增量版本,但我不能显示最新版本。下面是我尝试:
这是不行的,它会显示 1.0.0
,而不是从实际值 project.json
我也试过,但它看起来不再在RC2作品:
@Inject Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv
我的版本号是@(appEnv.ApplicationVersion)
根据 一>, IApplicationEnvironment
不再存在。
您仍可以访问 ApplicationVersion
静态使用:
这为我工作。我的 project.json
是这样的:
{
版本:1.0.0.2,
// 其他的
}
在我的索引视图,我在顶部以下行:
<$p$p><$c$c>@Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion和我正确地获得 1.0.0.2
输出。当我改变的价值和重启(版本)的应用,新的版本显示在那里。
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'm trying:
@(Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion)
This does not work, it displays "1.0.0
" instead of real value from project.json
I also tried this but it looks like it is no longer works in RC2:
@inject Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv
My version number is @(appEnv.ApplicationVersion)
As per this announcement, IApplicationEnvironment
no longer exists.
You can still access the ApplicationVersion
statically using:
Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion
It works for me. My project.json
looks like this:
{
"version": "1.0.0.2",
// all the rest
}
And in my index view, I have the following line at the top:
@Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion
And I correctly get 1.0.0.2
in the output. And when I change that value and restart (build) the application, the new version is shown there.
这篇关于显示项目版本的ASP.NET MVC核心应用(RC2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!