This article is a mirror article of machine translation, please click here to jump to the original article.

View: 19385|Reply: 0

[.NET Core] Create an MVC project ASP.NET the Core command line

[Copy link]
Posted on 6/28/2018 10:29:41 AM | | | |
Native development tools vs 2017, because it was installed last year, there has been no upgrade, we create a new .net core website project, find that there is only the 1.x version, we run dotnet --version, the system installed version is also 1.0.0, as shown below:



As a result,I want to create a .net core project with version 2.1, the tutorial is as follows:

Install the SDK

Download Address:The hyperlink login is visible., download and double-click to install, as shown below:



After the installation is completed, re-run the "dotnet --version" command to check the version, and find "2.1.301", which is already the latest version.But vs2017 still can't create a 2.x project!!!



New MVC project

Since we cannot create a project using the VS IDE tool, we can only create an MVC project through the command line, the command is as follows:


C:\project\web\test>dotnet new mvc
The template "ASP.NET Core Web App (Model-View-Controller)" has been successfully created.
This template contains technologies for non-Microsoft parties, see For more informationThe hyperlink login is visible.

Processing post-creation operations...
Running "dotnet restore" on C:\project\web\test\test.csproj...
  Reverting the package of C:\project\web\test\test.csproj...
  Microsoft.NETCore.DotNetAppHost 2.1.0 is being installed.
  Microsoft.NETCore.DotNetHostResolver 2.1.0 is being installed.
  Microsoft.NETCore.DotNetHostPolicy 2.1.0 is being installed.
  Microsoft.NETCore.Targets 2.1.0 is being installed.
  Installing Microsoft.NETCore.App 2.1.0.
  MSBuild file C:\project\web\test\obj\test.csproj.nuget.g.props is being generated.
  MSBuild file C:\project\web\test\obj\test.csproj.nuget.g.targets is being generated.
  The restore of C:\project\web\test\test.csproj was completed within 9.24 sec.

Restore successfully.



The introduction of new project types is as follows:

C:\project\web\test>dotnet new --help
Usage: new [Options]

Options:
  -h, --help shows help for this command.
  -l, --list list templates that contain the specified name. If you don't specify a name, list all templates.
  -n, --name is creating the name of the output. If no name is specified, the name of the current directory is used.
  -o, --output where you want to place the generated output.
  -i, --install install the source or template package.
  -u, --uninstall to uninstall a source or template package.
  --nuget-source specifies the NuGet source to be used during installation.
  --type filter templates based on available types. The predefined values are "project", "item", or "other".
  --force forces the content to be generated, even if that content changes the existing file.
  -lang, --language filter templates based on language and specify the language of the template to be created.


Template Short Name Language tag
----------------------------------------------------------------------------------------------------------------------------
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
Razor Page                                        page               [C#]              Web/ASP.NET
MVC ViewImports                                   viewimports        [C#]              Web/ASP.NET
MVC ViewStart                                     viewstart          [C#]              Web/ASP.NET
ASP.NET Core Empty                                web                [C#], F#          Web/Empty
ASP.NET Core Web App (Model-View-Controller)      mvc                [C#], F#          Web/MVC
ASP.NET Core Web App                              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
Razor Class Library                               razorclasslib      [C#]              Web/Razor/Library/Razor Class Library
ASP.NET Core Web API                              webapi             [C#], F#          Web/WebAPI
global.json file                                  globaljson                           Config
NuGet Config                                      nugetconfig                          Config
Web Config                                        webconfig                            Config
Solution File                                     sln                                  Solution

Examples:
    dotnet new mvc --auth Individual
    dotnet new webapi
    dotnet new --help

After the new creation is completed, directly drag the test folder into the VS code development tool, and then you can run and debug normally, as shown in the figure below:



Finally, a link to the .NET Core development documentation:The hyperlink login is visible.

Resources:
https://www.cnblogs.com/linezero/p/5688772.html
https://www.jianshu.com/p/7b8060345f48




Previous:CentOS 7 runs the .NET Core website error solution
Next:Solution to the error after closing the vim editor abnormally
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com