Hello World From .NET Core 2 And VS 2017 Preview And Difference In csproj

Yesterday, Microsoft announced about preview release from .Net Core 2 and Visual Studio 2017 preview,

In this topic we will learn:

  • Benefits of using .Net Core 2
  • How to install visual studio 2017 preview
  • How to install .net core 2
  • How to create a Hello World web app
  • The difference between the .csproj file in .NET Core 2 and .csproj in .Net Core 1.1 With VS 2017 Preview

Some of the benefits of using .NET Core 2 include it has a lot of APIs related to .NET Core 1 and has support for Visual Basic.

Now, let’s go to install them and create "Hello World" from .NET Core 2

Step 1

To install Visual Studio 2017 Preview, click here.

Step 2

Choose the edition which you have license for. If you don’t have license, choose Community Edition.

.Net Core

Step 3

Run the exe and wait for some seconds. Then, choose the following options.

.Net Core

.Net Core

Step 4

Click "Install" and it will look like the follwoing screen where I have VS 2017 and VS 2017 Preview. Both can work side by side without any problem.


.Net Core

When the installation is completed, click "Launch".

.Net Core

Step 5

Select File >> New >> Project then choose ASP.NET Core Web App and press OK. 

.Net Core

Step 6

Go to the dropdown list to choose the version of the .NET Core you want.

.Net Core

Ooh! Where is ASP.NET Core 2 ??

So, open the command line and write dotnet –version to see which version you have used now.

.Net Core


The answer to the above question is, ASP.NET Core is a separated download, so click here and download and run the exe.

Step 7

Check the "I agree...." check box and press Install.

.Net Core


.Net Core

Finally, click "Close".

Step 8

Now, open command line and write dotnet –version to see which version you have used.

.Net Core

Step 9

Open Visual Studio and repeat steps 5 and 6. Now, you see ASP.NET Core 2.

.Net Core

Choose it, then choose empty template.

.Net Core

Step 10

Go to Startup.cs and write the following script.

.Net Core

Run the app now. The result should be something like below.


.Net Core

Now, let’s open a csproj file in full template project with .NET core 1.1 and open a csproj file in full template project in .NET Core 2.

Right click on the project and edit csproj. It will look like the following in .NET core 1.1 

  1. <Project Sdk="Microsoft.NET.Sdk.Web">  
  2.   
  3.   <PropertyGroup>  
  4.     <TargetFramework>netcoreapp1.1</TargetFramework>  
  5.     <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>  
  6.   </PropertyGroup>  
  7.   
  8.   <ItemGroup>  
  9.     <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />  
  10.     <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />  
  11.     <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />  
  12.     <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />  
  13.     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />  
  14.     <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />  
  15.   </ItemGroup>  
  16.   
  17.   <ItemGroup>  
  18.     <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />  
  19.   </ItemGroup>  
  20. </Project>    

But now in .NET Core 2 

  1. <Project Sdk="Microsoft.NET.Sdk.Web">  
  2.   
  3.   <PropertyGroup>  
  4.     <TargetFramework>netcoreapp2.0</TargetFramework>  
  5.     <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>  
  6.     <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>  
  7.     <UserSecretsId>aspnet-WebApplication2-19927FA3-AE04-4DE8-A3ED-A8AE9EDD3BF9</UserSecretsId>  
  8.   </PropertyGroup>  
  9.   
  10.   <ItemGroup>  
  11.     <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />  
  12.   </ItemGroup>  
  13.   
  14.   <ItemGroup>  
  15.     <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview1-final" />  
  16.   </ItemGroup>  
  17. </Project>   

If you look at PackageReference now, it’s just one package called Microsoft.AspNetCore.All. Actually, it’s very short and nice look.


Similar Articles