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:
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”