This post just explains some of the things you need to do when updating to ASP.NET Core 1.0 beta8 from older versions. I have updated some existing ASP.NET Core 1.0 example projects to beta8.
The first thing you have to do is to update your dnvm, dnu and your dnx. This is the same as always. Documentation can be found here for windows, mac and linux. You must also update your Visual Studio Web tools because the new httpplatformhandler needs to be installed in the IIS Express. This also needs to be updated in the IIS depending how you deploy your projects.
Updating your MVC 6 project
I usually update the project.json file first. Here is an example of some of the beta8 references which are usually required in a MVC 6 project. The Microsoft.AspNet.IISPlatformHandler is a new dependency. The commands also need to be updated. Now the web command uses kestrel.
"dependencies": { "Microsoft.AspNet.Diagnostics": "1.0.0-beta8", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8", "Microsoft.AspNet.Mvc": "6.0.0-beta8", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8", "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8", "Microsoft.AspNet.StaticFiles": "1.0.0-beta8", "Microsoft.Framework.Logging": "1.0.0-beta8", "Microsoft.Framework.Logging.Console": "1.0.0-beta8", "Microsoft.Framework.Logging.Debug": "1.0.0-beta8", "NEST": "1.7.0", "Microsoft.Net.Http": "2.2.29", "Microsoft.AspNet.SignalR.Server": "3.0.0-beta8-15656", "NEST.Watcher": "1.0.0-beta2" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:17202" },
Once everything is restored, you must replace your web.config file inside the wwwroot folder in your MVC 6 application. Replace it with the following:
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" /> </handlers> <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" /> </system.webServer> </configuration>
The Startup class requires some changes as well. The main change is that the “app.UseIISPlatformHandler();” middleware is now required. The configuration and the UseExceptionHandler have also been updated/added. Here’s an example of a beta8 Startup class. You could also use yoeman to get a beta8 template.
using AspNet5Watcher.Configurations; using AspNet5Watcher.SearchEngine; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.Dnx.Runtime; using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; namespace AspNet5Watcher { public class Startup { public IConfigurationRoot Configuration { get; set; } public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) { var builder = new ConfigurationBuilder() .SetBasePath(appEnv.ApplicationBasePath) .AddJsonFile("config.json"); Configuration = builder.Build(); } public void ConfigureServices(IServiceCollection services) { services.Configure<ApplicationConfiguration>(Configuration.GetSection("ApplicationConfiguration")); services.AddMvc(); services.AddSignalR(options => { options.Hubs.EnableDetailedErrors = true; }); services.AddScoped<SearchRepository, SearchRepository>(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseExceptionHandler("/Home/Error"); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseSignalR(); } } }
Then of course your code will require some changes. For example filters have been moved to a new namespace, or the configuration options uses the Value property not like before, or Entity Framework Entity class has replaced the Key property with HasKey. There are lots of breaking changing in this version, but it is a beta version. Here’s a list of breaking changes.
I also had an issue with ports and the kestrel server.
https://github.com/aspnet/Home/issues/993
Links
http://blogs.msdn.com/b/webdev/archive/2015/10/15/announcing-availability-of-asp-net-5-beta8.aspx
https://github.com/aspnet/Home/releases/tag/v1.0.0-beta8
[…] ASP.NET 5 updating to beta8 from older beta versions – damienbod also discusses the ASP.NET 5 Beta 8 release, and looks at the steps needed to upgrade your earlier beta based projects […]
Thank you very much for the comprehensive instructions!
However there is one thing i don’t quite get: I can’t find a beta8 version of Microsoft.AspNet.SignalR.Server. I was only able to install the beta7 Version which throws some MissingMethodExceptions at me at runtime.
The Package Manager Console Outputs the following Information:
Unable to locate Dependency Microsoft.AspNet.SignalR.Server >= 3.0.0-beta8
Writing lock file C:\Daten\Projekte\xxx\src\xxx\project.lock.json
Restore complete, 1469ms elapsed
Errors in C:\Daten\Projekte\xxx\src\xxx\project.json
Unable to locate Dependency Microsoft.AspNet.SignalR.Server >= 3.0.0-beta8
NuGet Config files used:
C:\Users\Markus\AppData\Roaming\NuGet\nuget.config
C:\Daten\Projekte\xxx\nuget.config
Feeds used:
https://api.nuget.org/v3-flatcontainer/
C:\Program Files (x86)\Microsoft Web Tools\DNU
Any idea what might be the Problem here?
Thanks a lot for your help!
Hi Markus
I’m using “Microsoft.AspNet.SignalR.Server”: “3.0.0-beta8-15656”, directly, missing form beta8 as you said.
here’s an example
https://github.com/damienbod/AspNet5Watcher/blob/master/src/AspNet5Watcher/project.json
Greetings Damien
Thank you for the prompt Reply, Damien.
Unfortunately this package seems to be offline. It also can’t get restored when i open your demo project on GitHub.
Kind Regards
Markus
Hi Markus
Do you have the following feeds configured in your NuGet package sources?
https://www.myget.org/F/aspnetvnext/
https://api.nuget.org/v3/index.json
Greetings Damien
[…] DamienBod Updating to Beta8 from Older Beta Versions […]