Objective
A few days ago, the. NET core released the. NET Core 1.0.1 R2 preview, before thinking about having time to try. NET Core. For various reasons, there is no preliminary examination. Just a few days ago to see. NET Core released a new version, decided to go to explore. So, immediately go to the official website to find relevant information, to prepare for a preliminary study.
Here's the beginning of today's content, with two sections: Installing and creating sample programs.
Installation
I am using the Windows 64-bit system, installed the Visual Studio, if not installed, please install first.
Download the installation file
Go to the. NET core website, go to download page 1, go to download page 2, download the required installation files.
Files that need to be downloaded:
- . NET Core Installer (RC2)
- . NET Core SDK Installer (Preview 1)
- Windows (Server Hosting)
- Dotnetcore.1.0.0.rc2-vs2015tools
- NuGet Manager extension for Visual Studio
The Windows system downloads the installation files directly.
Windows (Server Hosting) is the equivalent of IIS, which is the service host program for. NET Core Web projects, that is, you can run Web projects directly using Server Hosting.
Install the. NET Core
Tip: Uninstall the previous version of. NET Core before you get an error.
Error message:
The project is configured the. NET Core SDK version 1.0.0-preview1-002702 which are not installed or cannot be found und Er the path C:\Program files\dotnet\bin. These components is required to build and run this project. NetCoreR2.Sample.ConsoleApp
Double-click on the downloaded dotnetcore.1.0.0.rc2-runtime-x64.exe, select Agree agreement, then click "Insteall" to install, wait for the installation to finish.
Install the. NET Core SDK
Double-click on the downloaded dotnetcore.1.0.0.rc2-sdk.preview1-x64.exe, select Agree agreement, then click "Insteall" to install, wait for the installation to finish.
Installing Server Hosting
Double-click on the downloaded dotnetcore.1.0.0.rc2-windowshosting.exe, select Agree agreement, then click "Insteall" to install, wait for the installation to finish.
Installing the. NET Core Vs2015tools
Double-click on the downloaded dotnetcore.1.0.0.rc2-vs2015tools.preview1.exe, select Agree agreement, then click "Insteall" to install, wait for the installation to finish.
Installing nuget Manager extension for Visual Studio
Double-click on the downloaded NuGet.Tools.vsix, select Agree agreement, then click "Insteall" to install, wait for the installation to finish.
NuGet Manager Extension for Visual Studio Download
Example
Examples are the console program and the ASP. NET Core Web program.
. NET Core Console programs
Open Visual Studio 2015, create a new project: file-New-project
In the left-hand template, select . NET core, and on the right, select Console Application (. NET Core).
Enter NetCoreR2.Sample.ConsoleApp
a name and click on the "OK" button.
Ok,.net Core Console application creation is complete.
Open the Program.cs file, write the code, run it.
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;namespace NetCoreR2.Sample.ConsoleApp{ public class Program { public static void Main(string[] args) { Console.WriteLine("Hello .NET Core 1.0.0 R2 Console App!"); Console.ReadLine(); } }}
If you are prompted here
ASP. NET Core Web project
Create a new ASP. NET Core Web project on the solution above: Add-New project
Select ASP. NET Core Web application, and click "OK" to create the project.
Select Web Application
Change the authentication to: Do not authenticate, and then OK.
After you create the project, wait for the Neget package to restore, and then press "F5" to debug the run. You can choose IIS or Windowshosting, which is the latter.
Next, write a controller yourself and display the information.
Create a Hellocontroller controller and add an action for Index :
Using System;Using System.Collections.Generic;Using System.Linq;using System.Threading.Tasks; using MICROSOFT.ASPNETCORE.MVC; //for more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwli nk/? Linkid=397860namespace netcorer2.sample.webapp.controllers{ public class HelloController: Span class= "Hljs-title" >controller {//GET:/<controller>/ public iactionresult Index ( "MSG"] = "Hello. NET Core 1.0.0 R2 ASP. NET Core MVC app! "; return View (); }}
Create the corresponding view file and write the code:
@{ ViewData["Title"] = "Hello Index Page";}"Msg"].ToString()
This article is introduced here.
Please contact me if you have any questions.
Original:. NET Core R2 Installation and sample tutorials
. NET Core R2