Setup for Asp .Net Core 2.0

core2

Microsoft has announced Core 2.0 and it has some awesome features which I will explain in future blog posts.

For now, let us see how to converts your Core 1.0 application into Core 2.0

First of all, we will change the .Net core version in global.json file as shown below:

{
   "sdk": {
   "version": "2.0.0-preview3-006912"
  }
}

After that we need to change the target library to Core 2.0 as shown below:

1-TargetFramework

Also, change and update below line in .csproj file:

<TargetFramework>netcoreapp2.0</TargetFramework>

Once it is done, we need to add below package in the .csproj file:

<ItemGroup>

<PackageReference Include=“Microsoft.AspNetCore.All” Version=“2.0.0” />

</ItemGroup>

This new metapackage contains references to all of the AspNetCore packages and maintains a complete line-up of compatible packages.  You can still include explicit references to specific Microsoft.AspNetCore.* package versions if you need one that is outside of the lineup

Now we need to change PackageTargetFallback in same .csproj file as below:

<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

Here we added AssetTargetFallback instead of earlier PackageTargetFallback

Now let us jump to the Main method in Program.cs class. In Core 1.0 we used to add different extended methods like .UseKestrel(), .UseIISIntegration() etc.

For Core 2.0 it is more simplified as shown below:

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace AspNetCoreDotNetCore2._0App
{
   public class Program
   {
     public static void Main(string[] args)
     {
       BuildWebHost(args).Run();
     }

   public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
     .UseStartup()
      .Build();
  }
}

Now your application is converted into Core 2.0 from Core 1.0

3 thoughts on “Setup for Asp .Net Core 2.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s