.NET跨平台之旅:将示例站点升级至ASP.NET Core 1.0

北京时间6月28日凌晨,微软发布了 .NET Core 1.0,详见新闻 .NET Core 1.0 正式发布了 ,ASP.NET Core 1.0 也随之一起发布了。

紧跟这次发布,我们将跑在 Linux 服务器上的基于 ASP.NET Core RC2 的示例站点  about.cnblogs.com 进行了升级。

首先修改 NuGet.Config,删除下面的配置:

<add key="ASP.NET RC2" value="https://www.myget.org/F/aspnetrc2/api/v3/index.json" />

并将

<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />

改为

<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>

然后在 project.json 中将 1.0.0-rc2-final 都改为 1.0.0,将  "Newtonsoft.Json": "8.0.4-beta1" 改为 "Newtonsoft.Json": "9.0.1"

接着删除 Startup.cs 中的 app.UseRuntimeInfoPage(),这个特性暂时被去掉了,详见 https://github.com/aspnet/Diagnostics/issues/280

最后将视图 _Layout.cshtml 中的:

@{ var env = PlatformServices.Default.Runtime; }
&copy; 2004-@DateTime.Now.Year<a href="http://www.cnblogs.com">博客园</a> 
Powered by @($"dotnet-{env.RuntimeType.ToLower()}-{env.RuntimeVersion} on 
{env.OperatingSystemPlatform} {env.OperatingSystem}.{env.OperatingSystemVersion}-{env.RuntimeArchitecture}")

改为:

@{ var runtime = PlatformServices.Default.Application.RuntimeFramework; }
&copy; 2004-@DateTime.Now.Year<a href="http://www.cnblogs.com">博客园</a> Powered by @runtime.FullName

在 ASP.NET Core 1.0 中,RuntimeEnvironment 被从 PlatformAbstractions 中去掉了,详见 https://github.com/aspnet/Announcements/issues/191

完成这些操作之后,升级成功。

posted @ 2016-06-30 18:45  博客园团队  阅读(967)  评论(3编辑  收藏  举报