.net core 创建web项目

环境:ubuntu 16.04

.net core 2.2

 

直接使用命令 :dotnet new  可以查看到能创建的项目类型

hcy@hcy-System-Product-Name:~/dotnet/project$ dotnet new
Usage: new [options]

Options:
  -h, --help          Displays help for this command.
  -l, --list          Lists templates containing the specified name. If no name is specified, lists all templates.
  -n, --name          The name for the output being created. If no name is specified, the name of the current directory is used.
  -o, --output        Location to place the generated output.
  -i, --install       Installs a source or a template pack.
  -u, --uninstall     Uninstalls a source or a template pack.
  --nuget-source      Specifies a NuGet source to use during install.
  --type              Filters templates based on available types. Predefined values are "project", "item" or "other".
  --dry-run           Displays a summary of what would happen if the given command line were run if it would result in a template creation.
  --force             Forces content to be generated even if it would change existing files.
  -lang, --language   Filters templates based on language and specifies the language of the template to create.


Templates                                         Short 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                          
NUnit 3 Test Project                              nunit              [C#], F#, VB      Test/NUnit                           
NUnit 3 Test Item                                 nunit-test         [C#], F#, VB      Test/NUnit                           
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                              webapp             [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 nunit-test
    dotnet new --help
hcy@hcy-System-Product-Name:~/dotnet/project$ 

比如要创建web类型项目 那就 :  dotnet new webapp -o  webapptest   /tmp/project/

这里webapptest 是项目名称  

如果想启动项目那就进到项目目录: cd  webapptest/  里运行 dotnet run webapptest 就能启动了。

启动后会有提示信息如下:

hcy@hcy-System-Product-Name:~/dotnet/project/testweb_app$ dotnet run testweb_appinfo: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using '/home/hcy/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Development
Content root path: /home/hcy/dotnet/project/testweb_app
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

 

 出现上边的信息就证明成功了。

打开浏览器访问 localhost:5000

会就进入到项目主页了。.net core 创建web项目_第1张图片

 

 

你可能感兴趣的:(.net,core)