. Netcore entry,. netcore

Source: Internet
Author: User

. Netcore entry,. netcore

Development Environment: windows Editor: Visual Studio Code

Environment installation:

. Net Core 1.1 SDK https://www.microsoft.com/net/core#windowscmd

 

1. Create a console project (see https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/using-with-xplat-cli)

1.1 after installing the. Net Core 1.1 SDK, open the cmd command window and enter dotnet. The following information is displayed, indicating that the installation is successful.

E:\lindy\netcoreproject\aspnetcoreapp>dotnetMicrosoft .NET Core Shared Framework Host  Version  : 1.1.0  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86Usage: dotnet [common-options] [[options] path-to-application]Common Options:  --help                           Display .NET Core Shared Framework Host help.  --version                        Display .NET Core Shared Framework Host version.Options:  --fx-version <version>           Version of the installed Shared Framework touse to run the application.  --additionalprobingpath <path>   Path containing probing policy and assemblies to probe for.Path to Application:  The path to a .NET Core managed application, dll or exe file to execute.If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.To get started on developing applications for .NET Core, install the SDK from:  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

1. 2. Enter the following command. You can see that a console project is created under the hwapp directory. In the cmd Console window, you can see "Hello World! "Output

md hwapp
cd hwapp
dotnet newdotnet restoredotnet run

1.3 debug the project under vscode

Open the hwapp folder with vscode. Find the C # extension in the extension menu and install it. Click the Debug menu, click the settings bar, and select.. net core as the debug environment; open program. cs file, click Start debugging (F5), run and you will see the debugging console "Hello World! "Output (ps: debug the currently opened file by default)

 

2. New asp.net core program (https://docs.microsoft.com/zh-cn/aspnet/core/getting-started)

2.1 create a project

Md aspnetcoreapp

Cd aspnetcoreapp

Dotnet new-t web

2.2 restore the package file (ps: default path of the nuget package, under the current user. in the nuget folder, for example, C: \ Users \ lindanyang \. nuget, that is, all the nuget packages we load are in this path)

Dotnet restore

The following error may be reported due to the wall:

Error: Failed to retrieve information from remote source 'HTTP: // go. microsoft. co
M/fwlink /? LinkID = 206669/FindPackagesById ()? Id = 'Microsoft. AspNetCore. Diagnostics.
Entityframeworkcore ''.
Error: Response status code does not indicate success: 301 (Moved Permanently ).

Solution: add the NuGet. config file under the project path and add the nuget Source

The configuration is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<PackageSources>
<! -- To inherit the global NuGet package sources remove the <clear/> line below -->
<Clear/>
<Add key = "dotnet-core" value = "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json"/>
<Add key = "api.nuget.org" value = "https://api.nuget.org/v3/index.json"/>
<Add key = "AspNetCI" value = "https://www.myget.org/F/aspnetcirelease/api/v3/index.json"/>
</PackageSources>
</Configuration>

2.3 website running

Dotnet run

. Net core version configuration problems may also cause the following errors:

The specified framework 'Microsoft. NETCore. app', version' 1. 1.0-preview1-001153-
00 'was not found.
-Check application dependencies and target a framework version installed:
C: \ Program Files \ dotnet \ shared \ Microsoft. NETCore. App
-The following versions are installed:
1.1.0
-Alternatively, install the framework version '1. 1.0-preview1-001153-00 '.

Solution:

Obtain the. net core Version based on the dotnet command and modify the. net core Version of the project. json file. if the Version of the nuget package is incorrect, modify the following:

  "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",  "dependencies": {    "Microsoft.NETCore.App": {      "version": "1.1.0",      "type": "platform"    },

Run the dotnet restore and dotnet run commands again.

 

2.4 open the website, as shown in

Http: // localhost: 5000/

 

 

2.5 The project file contains the README. md file, which contains the web project-related tutorial URL for further study.

Vscode-related operations to be continued ~~~~~~~~~~~~~~~~~

Related Article

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.