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
Ltslong Term Support (LTS) releases is supported for three years, so they is recommended if you want to stay in the Same version for a long period of time. LTS version now is
. NET Core 1.0.3 currentcurrent releases include the latest features and is supported for three months after the next release so you Should always stay in the latest version. Current version are
. NET Core 1.1 sdkthe SDK includes the runtime and command line tools for creating. NET Core Applicationsruntimethe Runtime does not include the tools and can only is used to run. NET Core applications.
|
. NET core 1.0.3 sdk-installer |
. NET Core 1.0.3 Sdk-binari Es only |
Windows |
x64/x86. exe |
x64/x86 . zip |
macOS |
x64. Pkg |
x64. tar.gz |
linux |
installing. NET Core on Linux |
do Cker |
installing. NET Core on Docker |
Visual Studio T Ools (Preview 2) |
x64/x86. exe |
Visual Studio Tools (Preview 3) |
installing. NET core tools in Visual Studio installing. NET core RC3 tools for all Oth ER platforms |
only
|
. NET core 1.0.3 runtime-installer |
. NET core 1.0.3 runtime-binaries |
Windows |
X64/x86. exe |
X64/x86. zip |
Windows Server Hosting |
X64/x86. exe |
- |
MacOS |
x64. Pkg |
x64. tar.gz |
Linux |
Installing. NET Core on Linux |
Docker |
Installing. NET Core on Docker |
|
. NET Core 1.1 Sdk-installer |
. NET Core 1.1 Sdk-binaries O nly |
Windows |
x64/x86. exe |
x64/x86. zip |
macOS |
x64. Pkg |
x64. tar.gz |
linux |
installing. NET Core 1.1 on Linux |
Docker |
installing. NET Core 1.1 on Docker |
Visual Studio Tools (Preview 2) * |
x64/x86. EXE |
Visual Studio Tools (Preview 3) * |
installing. NET Core Tools in Visu Al Studio Installing. NET Core RC3 Tools for all other platforms |
(*) Visual Studio tools include. NET Core 1.0.1. To add. NET core 1.1, need to also install the. NET core 1.1 runtime.
only
|
. NET Core 1.1 Runtime-installer |
. NET Core 1.1 Runtime-binaries |
Windows |
x64/ x86. exe |
x64/ x86 .zip |
Windows Server Hosting |
X64/x86. exe |
- |
MacOS |
x64. Pkg |
x64. tar.gz |
Linux |
Installing. NET Core 1.1 on Linux |
Docker |
Installing. NET Core 1.1 on Docker |
Step-by-Step instructions Windows MacOS Linux
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 to use. NET Core SDK version 1.0.0-preview1-002702 which are not installed or cannot be fou nd under 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). EnterNetCoreR2.Sample.ConsoleAppa 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/fwlink/?LinkID=397860 namespace NetCoreR2.Sample.WebApp.Controllers
{ public class HelloController : Controller
{ // GET: /<controller>/ public IActionResult Index()
{
ViewData["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";
}
<h3>@ViewData["Msg"].ToString()</h3>
This article is introduced here. Please contact me if you have any questions.
. NET Core R2 Installation and sample tutorials