After a long wait, ASP.NET Core RC2 was released yesterday. Finally.. Earlier I posted about Quick summary of what’s changed in ASP.NET 5 but after that ASP.NET 5 was renamed to ASP.NET Core 1.0 and earlier this year ASP.NET team in NDC conference gave overview of what’s coming and what’s new in ASP.NET Core RC 2. And in mid April 2016 ASP.NET team gave a glimpse of ASP.NET Core RC2, when they published a sample project on github using ASP.NET Core RC2. I also covered it in my post First look at ASP.NET Core 1.0 RC2. Since RC2 is finally out, so in this post, find a quick and short summary of what’s new and what’s changed in ASP.NET Core RC2.
Quick summary of what’s changed in ASP.NET Core RC2
[UPDATE: ASP.NET Core 2.0 is out. Please read What’s new in ASP.NET Core 2.0
Don’t expect any major changes compare to RC1. As most of these are more of forced changes due to renaming. But these are code breaking changes.
- The first and most important change is that DNX is gone. And it is replaced by dotnet cli tool. This tool also replaces dnvm (DotNet Version Manager) and dnu (Dotnet Developer Utility).
dnx run
anddotnet run
commands are different.dnx run
makes in-memory compilation wheredotnet run
is more like a traditional method. Read Difference between “dnx run” and “dotnet run”. So with RC2, incremental compilation is back. Just compile what is changed.- ASP.NET Core is a pure console app. When you create a new ASP.NET Core web application targeting RC2, you will find program.cs file with following line of code.
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); }
Previously,
static void Main()
method was part of Startup.cs. - web.config is back. In RC1, you will find
app.UseIISPlatformHandler()
in configure method of Startup.cs. But this middleware is not available in RC2. It is replaced withUseIISIntegration()
. See static void main code above. The point here is that HttpPlatformModule was replaced by ASP.NET Core Module. And web.config now holds the configuration of ASP.NET Core module.<configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/> </system.webServer> </configuration>
- All
Microsoft.AspNet.*
namespaces are renamed toMicrosoft.AspNetCore.*
. TheEntityFramework.*
packages and namespaces are changing toMicrosoft.EntityFrameworkCore
. So you need to manually edit your project.json file to update package information while migrating to RC2 from RC1. - There is now separate web application templates for .NET Core and .NET Framework, when you create new project in VS 2015. Read Difference between .NET Core and .NET Framework.
- All environment variables are now prefixed with the
ASPNETCORE_
prefix. SoASPNET_ENVIRONMENT
is nowASPNETCORE_ENVIRONMENT
. - Till RC1, To use tag helpers in MVC Core, you need to make reference of it in Project.json but with RC2 it is added by default. Also the tag helper package name is changed to
Microsoft.AspNetCore.Mvc.TagHelpers
- Earlier, IApplicationEnvironment.ApplicationBasePath was used to get the application base path. but now use
IHostingEnvironment.ContentRootPath
. AndApplicationName
property is also moved toIHostingEnvironment
. Till RC1,public Startup(IHostingEnvironment env, IApplicationEnvironment appenv) { string sAppPath = appenv.ApplicationBasePath; }
In RC2,
public Startup(IHostingEnvironment env, IApplicationEnvironment appenv) { string sAppPath = env.ContentRootPath; }
-
If you’re using Entity Framework, update your
DbContext
class to accept an options parameter in its constructor and pass it to its base.public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
- Commands section is gone from Project.json.
compliationOptions
is now renamed tobuildOptions
.- Within
buildOptions
, there is a new entry"debugType": "portable"
"buildOptions": { "emitEntryPoint": true, "debugType": "portable" }
This is to generate cross-platform PDB files. If the entry is not present then generated PDB files will only be windows based. So if you wish to debug your code on cross-platform, set this to “portable”.
- The frameworks section now has different entries:
"frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "dnxcore50", "portable-net45+win8" ] } }
Platform mapping names are changed. So for .NET framework 2 to 4.6, the name would be
net20 – net46
and for .NET Core application, it would benetcoreapp
. And that’s why you see netcoreapp present in framework section. And within this, you will also see “imports” section which has value likeportable-net45+win8
. And the description says that it allows packages supporting these frameworks to be installed in this target, regardless of compatibility rules. - You will also find
runTimeOptions
section with 2 entries."runtimeOptions": { "gcServer": false, "gcConcurrent": true }
gcServer
enables/disables server garbage collection andgcConcurrent
enables/disables concurrent garbage collection. You must turn on server garbage collection inproject.json
or,app.config
when running ASP.NET projects on the full .NET framework.
Project.json changes
Though I highlighted the changes but just to let you know that Project.json for ASP.NET Core is going away.
Summary
There are many other small points which can be included in this list. But I want to keep this short and simple. If you come across any, please mention in comments section or send it on twitter/facebook. Thank you for reading and I hope it helped you. Keep visiting this blog and share this in your network. Please put your thoughts and feedback in comments section.
Hi,
Yes, it makes sense. Thank you for a detailed answer.
Have a nice day!
Hi,
What do you mean by project.json is going away? Are we going to use web/app.config again?
Barbaros,
Yes. Project.json is going away. Project.json is currently used for all nuget package referencing, project referencing, publish command and etc.. So Post RTM release, this will be replaced with .csproj (as it is today with .NET 4.5 framework). So all project references will be now part of .csproj. Probably they may keep it for nuget references but not clear at this point of time. The reason why they are doing this is because to bring similarity across all project structures.
Hope this helps you.
Thanx for the summary.
I realy like those articles
Thank you
Glad that you liked it.