Last week, ASP.NET Core RC2 was released and I posted a summary of what’s changed in ASP.NET Core RC2. And this post will take you through about how to install ASP.NET Core RC2 along with tooling and then creating your first .NET Core application using dotnet cli tool and then ASP.NET Core RC2 application.
Update: ASP.NET Core RTM is out. Read How to Install ASP.NET Core And Create Your First Application
How to Install ASP.NET Core RC2
Installation of ASP.NET Core RC2 is simple but choosing the correct one may be tricky. Follow below steps to install ASP.NET Core RC2.
Uninstall ASP.NET Core RC1
The RC2 installer doesn’t override previous installation. So if you already have ASP.NET Core RC1 installed then you have to manually uninstall it and then install ASP.NET Core RC2.
Download the tooling and install it
As mentioned in my earlier post, there will be a release for tooling (includes dotnet-cli) and a separate release for .NET Core and ASP.NET Core 1.0 RC2 runtime and libraries. So first let’s download and install tooling. With RC2 release, Microsoft has also put all the .NET Core related stuff on a new website dot.net (You can say dotdotnet. Though dotnet.net would have been good choice). So download the installer based on platform and architecture of your system from here. On that page, you will find a list of various downloads for each platform.
You probably only need to download one of these:
- .NET Core = Run apps with .NET Core runtime.
- .NET Core SDK = Develop apps with .NET Core and the SDK+CLI (Software Development Kit/Command Line Interface) tools.
So once downloaded, run the installer and this should install tooling on your system.
So when installation is finished, you should be able to create .NET Core application from command line.
Create your first .NET Core application
Let’s first verify the installation. So go to command prompt and type
dotnet --version
and you should see 1.0.0-preview1-002702 as output. So let’s create a new app. So execute following commands.
mkdir FirstNETCoreApp cd FirstNETCoreApp dotnet new //Creates a new .NET Core application dotnet restore //Restores all the dependencies. dotnet run //Compile and run the application.
And as an output for dotnet run
command, you should see “Hello World!” on command prompt. Congratulations for your first .NET Core RC2 app. Easy and straightforward. Isn’t?
Download the ASP.NET Core RC2 and install it
When you install tooling, you won’t get the RC2 templates in Visual Studio 2015. And as of now, with dotnet-cli you can’t create ASP.NET Core application. So download Visual Studio 2015 MSI installer from here. Note, the Visual Studio MSI installer requires that you should have Visual Studio 2015 Update 2 installed. So make sure to update your Visual Studio 2015 to Update 2. You can download Update 2 from here. If you don’t have Visual Studio already, you can download Visual Studio Community 2015 for free.
Once downloaded, run the Visual Studio MSI installer. You should see following setup screen.
And it will take sometime to finish. Okay, so all set now to create your first ASP.NET Core RC2 application.
Create your first ASP.NET Core RC2 application
With RC2, you will see separate templates for ASP.NET and ASP.NET Core project. Till RC1, this was not present. As you can see in below image. There are 3 options now.
- ASP.NET Web application (.NET Framework) – Option to create ASP.NET application using .NET Framework 4.6
- ASP.NET Core Web application (.NET Core) – To create cross-platform ASP.NET application using .NET Core
- ASP.NET Core Web application (.NET Framework)– To create ASP.NET Core web application targeting .NET 4.6 for windows platform only.
Also notice on right-hand side, there is a separate entry for .NET Core templates.
For this post, we shall create a ASP.NET Core Web application (.NET Core) option. Once you provide web application name and hit ok you should see following project template selection dialog. This now lists only those templates that are applicable to ASP.NET Core 1.0.
Select Web Application and click OK to create the project. Solution explorer should look like shown below.
I already covered the changes in my post about web.config, new program.cs file and project.json changes. So I recommend you to read the post for all changes in RC2.
Hit F5 and run the application. And you should see your application running with default ASP.NET Core template. Let’s modify code to display a welcome message on the screen. So open HomeController from the Controllers folder and modify the Index() action as follows:
public IActionResult Index() { ViewBag.Message = "My First ASP.NET Core RC2 running successfully!!!"; return View(); }
Now let’s modify the view to show the message. So go to Index.cshtml from the Views > Home folder and replace the HTML markup with :
<h1>@ViewBag.Message</h1>
And now just run the application and you should see your message in the browser.
Update: ASP.NET Core RTM is out. Read Quick Migration guide for ASP.NET Core RTM from RC2
Summary
In this post, I showed you how to install ASP.NET Core RC2 and tooling and also how to create simple .NET Core application and ASP.NET Core RC2 application. 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.
This is very informative and it’s really helpful. And here is other tutorial to publish .NET Core on shared hosting environment, http://windowswebhostingreview.com/asp-net-5-fully-released-how-to-publish-asp-net-5-in-shared-hosting/.
very useful for beginner s and for fresher software developers who want to build their career in dotnet.this helps him a lot thanks for sharing such a valuable content thanks agian for sharing this.
Can’t fix this error i’ve tried
Severity Code Description Project File Line Suppression State
Error MSB3644 The reference assemblies for framework “.NETFramework,Version=v4.5.1” were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. D:\Development\Practice\WebApplication1\src\WebApplication1\WebApplication1.xproj C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 1098