. NET Core QuickStart Tutorial 2, my first. NET Core App (Windows Post)

Source: Internet
Author: User
Tags dotnet xunit


First, preface
    • This development environment?
      1. Operating system: Windows ten X64
      2. SDK:. NET Core 2.0 Preview
Second, install the. NET Core SDK
    • 1. Download. NET Core
      : Https://www.microsoft.com/net/download/core
      Choose the corresponding version according to your computer situation
      . NET CORE 2.0:https://aka.ms/dotnet-sdk-2.0.0-preview2-win-x64

    • 2. Installation
      Microsoft produced, one-click installation, just one step, look at the picture:




iii. Familiar Command (CMD)
    • 1. View version

#Use the command prompt (cmd) or Windows PowerShell dotnet --version
    • 2. Optional parameter Introduction
Parameters introduction (en) Introduction (Ken's translator)
New Initialize. NET projects. Initialize project (equivalent to new project with VS template)
Restore Restore dependencies specified in the. NET project. Restore dependencies in a project (equivalent vs Create ASP, add dependent dependencies)
Run Compiles and immediately executes a. NET project. Start Project
Build Builds A. NET project. Compiling the project
Publish Publishes A. NET Project for deployment (including the runtime). Publish project (includes runtime)
Test Runs unit tests using the test runner specified in the project. Starting unit Tests
Pack Creates a NuGet package. Create a NuGet Package
Migrate Migrates a Project.json based project to a MSBuild based project. Migrating based on Project.json for MSBuild-compliant compilation
Clean Clean build output (s). Clears the output generated by the compilation in the project
Ql Modify solution (SLN) files. Modify the solution file. sln
Add ADD reference to the project. Add Reference
Remove Remove reference from the project. Remove reference
List List reference in the project. List references in a project
NuGet provides additional NuGet commands. Some of the NuGet package management operations can be done by using the NuGet parameters and attaching some parameters
Msbuild Runs Microsoft Build Engine (MSBuild). Compiling by using MSBuild
Vstest Runs Microsoft Test execution Command line Tool. Start the command line test tool
-v/-version Display. NET Core SDK version. View the. NET Core SDK version
-i/-info Display. NET Core information. View. NET Core Details
-d/-diagnostics Enable diagnostic output. Enable Diagnostics
-v/-verbosity Set the verbosity level of the command. Set up a lengthy command set?
-h/-help Show Help. View Help
Iv. HelloWorld Project
    • 1. Create a project
#Use command prompt (cmd) or Windows PowerShell
# 1, open the project folder (if not already created first)
d:
cd d: \ projects

# 2, create project
dotnet new console -o helloworld
#dotnet new: Create & Initialize Project
#console: template type (equivalent to VS creation project selection console application)
# -o: Specify the output path name, which can be understood as the project folder name, the default project name = project folder name, or you can use -n to specify the project name alone
#dotnet new console -n helloworld is equivalent to dotnet new console -o helloworld

#Execution output:
The template "Console Application" was created successfully.

Processing post-creation actions ...
Running ‘dotnet restore’ on helloworld \ helloworld.csproj ...
  Restoring packages for D: \ Projects \ helloworld \ helloworld.csproj ...
  Installing Microsoft.NETCore.DotNetAppHost 2.0.0-preview2-25407-01.
  Installing Microsoft.Packaging.Tools 1.0.0-preview2-25401-01.
  Installing Microsoft.NETCore.DotNetHostResolver 2.0.0-preview2-25407-01.
  Installing NETStandard.Library 2.0.0-preview2-25401-01.
  Installing Microsoft.NETCore.Platforms 2.0.0-preview2-25405-01.
  Installing Microsoft.NETCore.DotNetHostPolicy 2.0.0-preview2-25407-01.
  Installing Microsoft.NETCore.App 2.0.0-preview2-25407-01.
  Generating MSBuild file D: \ Projects \ helloworld \ obj \ helloworld.csproj.nuget.g.props.
  Generating MSBuild file D: \ Projects \ helloworld \ obj \ helloworld.csproj.nuget.g.targets.
  Restore completed in 7.04 sec for D: \ Projects \ helloworld \ helloworld.csproj.

Restore succeeded.

#Project files are in d: \ projects \ hellworld 
    • 2. Analysis of output results

# 1, show that the project was created according to the specified dotnet new console -o helloworld template
The template "Console Application" was created successfully.

# 2, and then actively called the dotnet restore command to restore the project references, and actively installed dependencies
Processing post-creation actions ...
Running ‘dotnet restore’ on helloworld \ helloworld.csproj ...
   Restoring packages for D: \ Projects \ helloworld \ helloworld.csproj ... 
    • 3. Operation

cd d: \ projects \ helloworld
dotnet run

#operation result
Hello World!

# Congratulations, your first .NET Core application was born

#Source code please check d: \ projects \ hellworld \ Program.cs file 
Five, remarks
    • Supported project templates
Short
Templates Name Language Tags
Console Application Console [C #], F #, VB Common/console
Class Library Classlib [C #], F #, VB Common/library
Unit Test Project MSTest [C #], F #, VB Test/mstest
XUnit Test Project Xunit [C #], F #, VB Test/xunit
ASP. NET Core Empty Web [C #] Web/empty
ASP. NET Core Web App (Model-view-controller) Mvc [C #], F # Web/mvc
ASP. NET Core Web App (Razor Pages) Razor [C #] Web/mvc/razor Pages
ASP. NET Core with Angular Angular [C #] Web/mvc/spa
ASP. NET Core with React.js React [C #] Web/mvc/spa
ASP. NET Core with React.js and Redux Reactredux [C #] Web/mvc/spa
ASP. NET Core Web API Webapi [C #] Web/webapi
Nuget Config Nugetconfig Config
Web Config Webconfig Config
Solution File Ql Solution
Razor Page Page Web/asp.net
MVC Viewimports Viewimports Web/asp.net
MVC Viewstart Viewstart Web/asp.net


Have to say: C # is. NET platform of the pro-son Ah


    • How do I know which parameters the command supports?
      Answer: Use good-help/-h parameter

#Example:
dotnet --help
dotnet new --help
dotnet restore --help
dotnet new console --help
dotnet new mvc --help 


 


    • Series name:. NET Core Quick Start Tutorials
    • Previous article:. NET core QuickStart Tutorial 1, opening: Talk about the things that. NET Core
    • Next:. NET core Quick Start Tutorial 3, my first. NET Core App (CentOS article)
    • This article was first published: 2017-07-14
    • This text link: https://ken.io/note/dotnet-core-qucikstart-helloworld-windows


. NET core Quick Start Tutorial 2, my first. NET Core App (Windows Post)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.