Create the first ASP. NET core application using Visual Studio code

Source: Internet
Author: User
Tags dotnet using git

Full text translated from:Your First ASP. Application on a Mac Using Visual Studio Code

This article will show you how to write your first ASP. NET core application on a Mac.

The content of this article:

    • Build the development environment
    • Building Applications with Yeoman
    • Developing ASP. NET applications using visual Studio core
    • Use Kestrel to run this application locally
    • Publish this application to Azure
    • Learning Resources

Build the development environment

Download and install. Net core and Visual Studio Code with C # extensions on your development machine.

Building Applications with Yeoman

Create an ASP. NET core project by following the steps shown in building Projects with Yeoman.

Developing ASP. NET applications using visual Studio core

    • Open Visual Studio Core

    • Expand File>open, and navigate to the ASP. NET Core directory you created

At the Terminal/bash prompt, run the dotnet Restore project dependency. Alternatively, you can enter command shift pin visual Studio core as shown, and then type the dot to achieve the same goal.

You can run directly in visual Studio core, including all of the commands referenced in the project.json file in dotnet restore .

This empty project template is only used to show "Hello world!". Open Startup.cs in visual Studio core to see how this project is configured.

If this is your first time using Visual Studio Core (or just using this tool), just know: This tool provides a very smooth, fast and concise way of working, and writing code with her is very efficient.

In the left navigation bar, the four icons represent four functions, respectively:

    • Explore
    • Search
    • Git
    • Debug

Explore allows you to quickly navigate to any directory in the file system and, of course, makes it easy to view recently used files. At the same time, she identifies the file that was not saved or the newly created folder. You can easily create files (you don't even have to open a separate window). Also, you can easily save all the files in the menu options.

Search allows you to quickly find the file name or file content in the files directory.

If you have Git installed, the code will be fully integrated with Git. You can initialize the repository, commit the code, and so on in Git.

Debug supports debugging-time interaction (interactive debugging of applications).

Visual Studio Core has a lot of exciting features. As you can see, unused using statements are underlined and you can use command when the lamp icon appears . Remove them. Classes and methods will also show how many times they have been referenced in this project. If you have used Visual studio,visual Studio core with many of the same shortcut keys, such as command K C to annotate a block of code,command k u is used to uncomment.

Use Kestrel to run this application locally

This example uses the Kestrel configuration. You can see it in the project.json file, where it is specified as a dependency.

{  "version":"1.0.0-*",  "compilationoptions": {    "Emitentrypoint":true  },  "Dependencies": {    "Microsoft.NETCore.App": {      "type":"Platform",      "version":"1.0.0-rc2-3002702"    },    "Microsoft.AspNetCore.Server.Kestrel":"1.0.0-rc2-final",    "Microsoft.Extensions.Logging.Console":"1.0.0-rc2-final"  },  "Frameworks": {    "netcoreapp1.0": {}  }}

    • Run the dotnet Run command to launch the app.
    • Open Browser, navigate to localhost:5000
    • Enter Ctrl + C to stop the network server

Publish this application to Azure

If you've developed an application, you can push changes to your production environment using GIT, which is integrated into visual Studio core and runs on Azure.

Initialize git

Initialize git under the folder you're using. Tap the Git icon and click the Initialize Git repository button.

To add a submission overview, press Enter or click the Checkmark icon to submit the modified file.

Git tracks changes, so when you change a file, Git displays the file that changed since you last submitted it.

Initializing Azure Website

You can use Git to deploy apps directly to Auzre Web apps.

    • Create a new Web App in Azure. If you don't have an azure account, you can create a new free account.
    • To support "Use GIT for continuous deployment" (continuous deployment using GIT), configure the Web App in Auzre.

Remember that the Git URL is assigned to the app in the Azure portal.

    • In the console window, add a remote service named Azure with the git URL you just remembered.

git remote add Azure https://[email protected]

    • Publish to Master.

Deploy with git push for Azure master .

    • Browse the deployed Web App. You should see the Hello world! displayed

Learning Resources

    • Visual Studio Code
    • Building Projects with Yeoman
    • Fundamentals

Create the first ASP. NET core application using Visual Studio code

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.