The. NET core experience builds the first app on a window

Source: Internet
Author: User

1. Install the. NET Core SDK

To create. NET apps, just download the. NET Core SDK for Windows, and this installer will install the latest stable version of the tool and place it in the environment variable path so that we can open the console from anywhere to run dotnet.

2, initialization of some code

The following shows a console program for Hello World

    1. Open a command prompt
    2. Switch directories to desktop CD C:\Users\yang\Desktop
    3. Enter the dotnet new console-o hwapp command, where dotnet New represents the creation of an application, and the console is the Type,- o hwapp to generate a directory called Hwapp (Hello World App shorthand), the generated program will be placed in this folder;
    4. Use CD Hwapp to enter the newly generated Hwapp directory

The console Application template creates a Program.cs file that will output "Hello world" to the console.

using System; namespace hwapp{    class  program    {        staticvoid Main (string  [] args)        {            Console.WriteLine ("Hello world! " );        }    }}
3. Usedotnet RunRun the program

So far, we've built and run the first. NET program. Here's the whole step:

C:\windows\system32>CD C:\users\yang\desktopc:\users\yang\desktop>dotnet New Console-o Hwapp Welcome to use. NET Core!---------------------to learn more about. NET Core, go to https:Aka.ms/dotnet-docs. Use dotnet--help to view available commands or go to https://aka.ms/dotnet-cli-Docs. Telemetry--------------. NET Core collects usage data to improve the user experience. The data is anonymous and does not contain command-line arguments. Data is collected by Microsoft and shared with the community. You can choose to use your favorite shell to set the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to1to exit telemetry. To learn more about the. NET Core tools Telemetry, visit https:aka.ms/dotnet-cli-Telemetry. Preparing for ... The template "Console application" was created successfully. Processing post-creation actions ... Running on Hwapp\hwapp.csproj"dotnet Restore"... Restoring Packages forC:\Users\yang\Desktop\hwapp\hwapp.csproj ...  Generating MSBuild file C:\Users\yang\Desktop\hwapp\obj\hwapp.csproj.nuget.g.props.  Generating MSBuild file C:\Users\yang\Desktop\hwapp\obj\hwapp.csproj.nuget.g.targets. Restore completedinch193.89 ms forC:\Users\yang\Desktop\hwapp\hwapp.csproj. Restore succeeded. C:\Users\yang\Desktop>CD Hwapp

C:\users\yang\desktop\hwapp>dotnet Run
Hello world!

Similarly, create a Web application

C:\users\yang\desktop>dotnet New Web-o webapp the template "ASP. NET Core Empty" was created successfully. This template contains technologies for non-Microsoft parties, for more information, see https:aka.ms/template-3PN. Processing post-creation actions ... Running on Webapp\webapp.csproj"dotnet Restore"... Restoring Packages forC:\Users\yang\Desktop\webApp\webApp.csproj ...  Generating MSBuild file C:\Users\yang\Desktop\webApp\obj\webApp.csproj.nuget.g.props.  Generating MSBuild file C:\Users\yang\Desktop\webApp\obj\webApp.csproj.nuget.g.targets. Restore completedinch2.65 sec forC:\Users\yang\Desktop\webApp\webApp.csproj. Restore succeeded. C:\Users\yang\Desktop>CD Webappc:\users\yang\desktop\webapp>dotnet runhosting environment:productioncontent root path:c:\users\yang\desktop\webappnow listening on:http: localhost:5000application started. Press Ctrl+C to shut down.info:microsoft.aspnetcore.hosting.internal.webhost[1] Request starting HTTP/1.1 GET Http://localhost:5000/info:microsoft.aspnetcore.hosting.internal.webhost[2] Request finishedinch75.0924ms 200info:microsoft.aspnetcore.hosting.internal.webhost[1] Request starting HTTP/1.1 GET Http://localhost:5000/favicon.icoinfo:microsoft.aspnetcore.hosting.internal.webhost[2] Request finishedinch0.459MS 200

In the same vein, let's take another MVC Web application

C:\users\yang\desktop\webapp>dotnet New MVC-o Mvcapp has successfully created the template "ASP. NET Core Web App (Model-view-Controller) ". This template contains technologies for non-Microsoft parties, for more information, see https:aka.ms/template-3PN. Processing post-creation actions ... Running on Mvcapp\mvcapp.csproj"dotnet Restore"... Restoring Packages forC:\Users\yang\Desktop\webApp\mvcApp\mvcApp.csproj ... Restoring Packages forC:\Users\yang\Desktop\webApp\mvcApp\mvcApp.csproj ... Restore completedinch1.48 sec forC:\Users\yang\Desktop\webApp\mvcApp\mvcApp.csproj.  Generating MSBuild file C:\Users\yang\Desktop\webApp\mvcApp\obj\mvcApp.csproj.nuget.g.props.  Generating MSBuild file C:\Users\yang\Desktop\webApp\mvcApp\obj\mvcApp.csproj.nuget.g.targets. Restore completedinch2.59 sec forC:\Users\yang\Desktop\webApp\mvcApp\mvcApp.csproj. Restore succeeded. C:\USERS\YANG\DESKTOP\WEBAPP>CD Mvcappc:\users\yang\desktop\webapp\mvcapp>dotnet runhosting environment:productioncontent root path:c:\users\yang\desktop\webapp\mvcappnow listening on: http:localhost:5000application started. Press Ctrl+c to shut.

. NET Core Getting Started tutorial

Concepts and architecture, ASP. NET core Introduction and ASP. NET Core Fundamentals.

How to select the. NET core and. NET Framework

. NET Core API Address

. NET Official Document Address

. NET Core Chinese documents

The. NET core experience builds the first app on a window

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.