Migrating to ASP.NET 5
Note - The libraries I indicate as not supported are specific to projects targeting dnxcore50 and the coreclr runtime. Some of these items are still supported by dnx451 and the clr and mono runtimes.
I've had a lot of success with porting eggsbenedict.info to ASP.NET 5, a few days ago I confirmed and tested a full port on Windows.
The process has required a lot of reading, a lot of trial and error, and mostly a continual iteration of the following;
- Dependency not supported
- Find replacement or workaround
- Repeat
*.csproj are no longer supported in ASP.NET 5, so rather than attempting to upgrade each project in my solution, I instead created new ASP.NET 5 Packages for each project, added my existing files files to them and edited them where required to get each project to build.
The following explains the details of some of the larger issues.
Entity Framework 6 not supported
I've upgraded to Entity Framework 7 here, which is a rewrite of Entity Framework. This brought with it the requirement to upgrade to AspNet.Identity 3, table schema changes and some migration changes including a work-around for seeding. Because it's a re-write, previous functionality from EF6 is sometimes not supported or available in a different place - and this is infact the case with alot of ASP.NET 5 making this website extremely helpful.
There are few gotcha's with EF7, including lazy loading not working out of the box and some dependency issues when putting your DataContext in a separate class library but workarounds exist for these. I can't help think it would have been easier to understand how EF7 was supposed to work if I could run the project's accompanying tests, however this doesn't seem to work and the issue's I opened, xunit #590, entityframework #3121 were closed without an immediate resolution available.
ASP.NET MVC 5 not supported
So an upgrade to ASP.NET MVC 6 ensued meaning I had to just accept the migration from Microsoft.AspNet.Web.Optimization to using TaskRunners - although I haven't actually attempted to properly implement bundling yet. I took some time to properly implement Dependency Injection in my services and I had to throw away my @helpers and write TagHelpers as custom @helpers are no longer supported. I also ditched DataTables because the .NET wrapper for it is currently broken, and wrote an AngularJs replacement.
No image manipulation
This is a pretty big one, seems like a huge omission in the ASP.NET 5 framework. System.Drawing is not a part of the framework (and won't be), and there currently exists no alternative for manipulating images. There exists this interesting discussion that shows some interns at Microsoft claiming responsibility for it, only to have the issue closed and unassigned without further comment.
I was using the excellent imageresizer to resize images on the fly, however due to the above issue it doesn't run on MVC 6. To solve this issue I run the command line version of imagemagick via a System.Diagnostics.Process
, and pre-size and save the images to an S3 bucket.
log4net not supported
Doesn't look like there's much intention at this point for the log4net guys to create an ASP.NET 5 supporting version, so I needed a replacement for it. It wasn't too difficult for me to role my own ILogger that uses EntityFramework 7 to save logs to the database. I'll look at splitting it out and making it open source at some stage - although it took so little code it may not be worth it.
AWS SDK not supported
I'm storing my images in an S3 bucket with Amazon Web Services, however the AWSSDK for .NET does not have support for ASP.NET 5. To solve this I call the AWSCLI from a System.Diagnostics.Process
.
Next step
The next step is to see if I can get this project running inside a docker container.