.NET Core R2安装及示例教程

Install for Windows - Visual Studio 2015

  1. 1

    Download Visual Studio 2015

    Make sure you have Visual Studio 2015 Update 3 installed.

    Download Visual Studio 2015 with Update 3

    Or just download Visual Studio 2015 Update 3 if you already have Visual Studio 2015 installed.

     
  2. 2

    Install the .NET Core tools preview for Visual Studio

    .NET Core tools add support for .NET Core projects in Visual Studio 2015.

    Download .NET Core 1.0.1 tools Preview 2

  3. 3

    Create a new .NET Core project

    Click on File / New project and select the project template C# / .NET Core / Console application (.NET Core).

  4. 4

    Add some code

    Write some code in your Main method.

  5. 5

    Run your application

    Click on the menu item Debug / Start debugging to launch and debug your new .NET Core application from Visual Studio.

  6.  

    And you're ready!

    You now have .NET core running on your machine!

    Visit the .NET Documentation to get access to additional tutorials, samples and the full .NET Core documentation.

前言

前几天.NET Core发布了.NET Core 1.0.1 R2 预览版,之前想着有时间尝试下.NET Core。由于各种原因,就没有初试。刚好,前几天看到.NET Core发布新版本了,决定要去一探究竟。于是乎,就立马去官网查找相关的信息,为初探做准备。

下面就开始今天的内容,有两个部分:安装和创建示例程序。

安装

本人使用的是Windows 10 64位系统,安装过Visual Studio 2015,如果没有安装,请先安装。

下载安装文件

进入.NET Core官网,进入下载页面1进入下载页面2,下载所需的安装文件。  需要下载的文件:

LTSLong Term Support (LTS) releases are supported for three years, so they are recommended if you want to stay in the same version for a long period of time. LTS version now is .NET Core 1.0.3CurrentCurrent releases include the latest features and are supported for three months after the next release, so you should always stay in the latest version. Current version now is .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 be used to run .NET Core applications.
  .NET Core 1.0.3 SDK - Installer .NET Core 1.0.3 SDK - Binaries Only
Windows x64 / x86 .exe x64 / x86 .zip
macOS x64 .pkg x64 .tar.gz
Linux Installing .NET Core on Linux
Docker Installing .NET Core on Docker
Visual Studio 2015 Tools (Preview 2) x64 / x86 .exe
Visual Studio 2017 Tools (Preview 3) Installing .NET Core tools in Visual Studio 2017 Installing .NET Core RC3 tools for all other platforms
  .NET Core 1.0.3 runtime - Installer .NET Core 1.0.3 runtime - Binaries Only
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 Only
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 2015 Tools (Preview 2) * x64 / x86 .exe
Visual Studio 2017 Tools (Preview 3) * Installing .NET Core tools in Visual Studio 2017 Installing .NET Core RC3 tools for all other platforms

(*) Visual Studio tools include .NET Core 1.0.1. To add .NET Core 1.1 support you need to also install the .NET Core 1.1 runtime.

  .NET Core 1.1 runtime - Installer .NET Core 1.1 runtime - Binaries Only
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系统直接下载安装文件即可。 Windows (Server Hosting)的作用相当于iis,是.NET Core Web项目的服务宿主程序,即可以直接使用Server Hosting运行Web项目。

安装.NET Core

提示:请先卸载.NET Core之前的版本,否则会报错。

报错信息: The project is configured to use .NET Core SDK version 1.0.0-preview1-002702 which is not installed or cannot be found under the path C:\Program Files\dotnet\bin. These components are required to build and run this project. NetCoreR2.Sample.ConsoleApp

双击下载的DotNetCore.1.0.0.RC2-Runtime-x64.exe,选择同意协议,然后点击"Insteall"安装,等待安装结束。

安装.NET Core SDK

双击下载的DotNetCore.1.0.0.RC2-SDK.Preview1-x64.exe,选择同意协议,然后点击"Insteall"安装,等待安装结束。

安装Server Hosting

双击下载的DotNetCore.1.0.0.RC2-WindowsHosting.exe,选择同意协议,然后点击"Insteall"安装,等待安装结束。

安装.NET Core VS2015Tools

双击下载的DotNetCore.1.0.0.RC2-VS2015Tools.Preview1.exe,选择同意协议,然后点击"Insteall"安装,等待安装结束。

安装NuGet Manager extension for Visual Studio

双击下载的NuGet.Tools.vsix,选择同意协议,然后点击"Insteall"安装,等待安装结束。 NuGet Manager extension for Visual Studio Download

示例

示例有控制台程序和ASP.NET Core Web程序。

.NET Core控制台程序

打开Visual Studio 2015,新建一个项目:文件-新建-项目

在左侧模板选择.NET Core,右侧选择控制台应用程序(.NET Core)。 输入名称NetCoreR2.Sample.ConsoleApp,点击"确定"按钮。 OK,.NET Core控制台应用程序创建完成。

打开Program.cs文件,写入代码,运行。

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();
}
}
}

如果在这里提示

ASP.NET Core Web项目

在上面的解决方案上新建一个ASP.NET Core Web项目:添加-新建项目

选择ASP.NET Core Web Application(.NET Core),点击"确定",创建项目。

选择Web 应用程序

更改身份验证为:不进行身份验证,然后确定。

创建好项目后,等待Neget包还原,然后按"F5",调试运行。可以选择IIS或WindowsHosting,在这选用后者。

接下来,自己写一个控制器,并显示信息。

创建一个HelloController控制器,添加一个Index的Action:

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();
}
}
}

创建对应的视图文件,写入代码:

@{
ViewData["Title"] = "Hello Index Page";
} <h3>@ViewData["Msg"].ToString()</h3>

本文就介绍到这里。 如有疑问请联系我。

.NET Core R2安装及示例教程的更多相关文章

  1. [.NET Core].NET Core R2安装教程及Hello示例

    前言 前几天.NET Core发布了.NET Core 1.0.1 R2 预览版,之前想着有时间尝试下.NET Core.由于各种原因,就没有初试.刚好,前几天看到.NET Core发布新版本了,决定 ...

  2. Oracle 11g R2安装手册(图文教程)For Windows

    1.Oracle 11g R2安装手册(图文教程)For Windows 1.下载Oracle 11g R2 for Windows版本,下载地址如下 官方网站: http://download.or ...

  3. .NET Core 开发之旅 (1. .NET Core R2安装教程及Hello示例)

    前言 前几天.NET Core发布了.NET Core 1.0.1 R2 预览版,之前想着有时间尝试下.NET Core.由于各种原因,就没有初试.刚好,前几天看到.NET Core发布新版本了,决定 ...

  4. .Net Core 1.0.0 RC2安装及示例教程

    前几天微软发布了.Net Core1.0.0 RC2 Preview版本,一直都想尝试下跨平台的.Net Core,一直拖到今天,也参考了下园友们的经验,闲时整理了一下安装的步骤,供大家参考. 我们要 ...

  5. .Net Core 1.0.0正式版安装及示例教程

    使用VS Code 从零开始开发调试.NET Core 1.0 RTM. .NET Core 是一个开源的.跨平台的 .NET 实现. VS Code 全称是 Visual Studio Code,V ...

  6. vscode 开发.net core 从安装到部署 教程详解

    一:环境准备: windows系统需要 win7 sp1 / windows 8  / windows 2008 r2 sp1 / windows10: 其他版本的windows系统在安装.NET C ...

  7. 安卓模拟器Android SDK 4.0.3 R2安装完整图文教程

    在最新的Android 4.0.3 R2模拟器中,已经加入了GPU支持,可以支持OpenGL ES 2.0标准,让开发者可以借助模拟器来测试自己的OpenGL游戏.在去年新增了摄像头支持之后,现在的新 ...

  8. .NET Core R2

    .NET Core R2安装及示例教程   前言 前几天.NET Core发布了.NET Core 1.0.1 R2 预览版,之前想着有时间尝试下.NET Core.由于各种原因,就没有初试.刚好,前 ...

  9. Oracle&nbsp;11g&nbsp;R2安装手册(…

    1.Oracle 11g R2安装手册(图文教程)For Windows 1.下载Oracle 11g R2 for Windows版本,下载地址如下官方网站:http://download.orac ...

随机推荐

  1. webpack vue-cli 常见问题总结

    1. webpack打包压缩 ES6 js..vue报错: ERROR in js/test.js from UglifyJs Unexpected token punc ?(?, expected ...

  2. PHP算法面试题目

    1.使用PHP描述冒泡排序和快速排序算法,对象可以是一个数组 //冒泡排序(数组排序) functionbubble_sort($array){       $count = count($array ...

  3. 永琳的竹林迷径(path)

    永琳的竹林迷径(path) 题目描述 竹林可以看作是一个n 个点的树,每个边有一个边长wi,其中有k 个关键点,永琳需要破坏这些关键点才能走出竹林迷径. 然而永琳打算将这k 个点编号记录下来,然后随机 ...

  4. 0-Broadcast机制原理简要介绍

    Broadcast机制简要介绍 来源: http://blog.csdn.net/luoshengyang/article/details/6730748 导语 广播机制在Android系统中,也不算 ...

  5. Redis+sentinel 高可用实践

    1.环境规划 10.213.50.138(主) redis+sentinel 10.213.50.168(从) redis+sentinel 10.213.50.227  作为客户端测试插入数 2.r ...

  6. 关于微信小程序并发数不能超过五个的问题

    wx.request 的最大请求数为5个,超过的部分就请求不到了 昨天遇到个问题,首页的请求数一共有9个,但是在有appid开发时竟然一直都没出错,直到我切到没appid的版本的时候才发现了这个问题. ...

  7. PHP一维数组和二维数字排序整理

    <?php /** 一维数组排序 sort() - 以升序对数组排序 rsort() - 以降序对数组排序 asort() - 根据值,以升序对关联数组进行排序 ksort() - 根据键,以升 ...

  8. .NET and php

    原文发布时间为:2011-12-29 -- 来源于本人的百度文章 [由搬家工具导入] http://www.php-compiler.net/blog/2011/phalanger-3-0

  9. repeater绑定数组、哈希表、字典 ArrayList/HashTable,Dictionary为datasource

    原文发布时间为:2009-11-19 -- 来源于本人的百度文章 [由搬家工具导入] repeater绑定数组、哈希表、字典datasource为ArrayList/HashTable,Diction ...

  10. C#中的继承与覆盖

    原文发布时间为:2009-03-03 -- 来源于本人的百度文章 [由搬家工具导入] //using System;//using System.Collections.Generic;using S ...