In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use ASP.NET Core command line interface CLI". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use ASP.NET Core command line interface CLI" can help you solve the problem.
CLI (Command Line Interface)
The .NET Core CLI (Command Line Interface) is a new cross-platform tool for creating, restoring, building, running, and publishing ASP.NET Core applications. The. NET Core CLI command that applies to any type of Web application uses out-of-process hosting, that is, it runs the application using a Kestrel server
So far, all the applications we have created have used Visual Studio. Visual Studio internally uses this. NET CLI command to restore, build, and publish applications. Other advanced IDE, editors, and tools, such as Visual Studio Code, use these CLI commands to support creating, restoring, publishing, and running .NET Core applications.
When we install the .NET Core SDK, the .NET Core CLI is also installed by default. Therefore, we do not need to install it separately on the development environment (that is, our local computer). We can use the command prompt to verify the same thing, that is, whether the .NET CLI is installed. To verify, open a command prompt (Windows), terminal (Linux), type "dotnet", and then press Enter, as shown below. If it shows usage and help options (as shown in the following figure), the .NET Core CLI is installed correctly.
.net Core CLI command structure
The .NET Core CLI command structure is just the way we write .NET Core CLI commands. The following is the command structure of the .NET Core CLI command:
Dotnet
Note: all .NET Core CLI commands begin with a driver named dotnet. The driver, the dotnet, starts executing the specified command. After dotnet, we need to specify commands (also known as verbs) to perform specific actions. Each command can be followed by parameters and options.
How to get all .NET Core commands
Open a command prompt (CMD), type dotnet help, and then press Enter, which displays all .NET Core CLI commands. Here are some commands and their usage.
Add: Add a package or reference to a .NET project (add a package or reference to a .NET project).
Build: Build a .NET project (build a .NET project).
Build-server: Interact with servers started by a build (interacts with the server started by the build).
Clean: Clean build outputs of a .NET project (cleaning up the build output of .NET projects).
Help: Show command-line help (displays command line help).
List: List project references for a .NET project (lists project references for .NET projects).
Msbuild: Run Microsoft Build Engine (MSBuild) commands (run the Microsoft Build Engine (MSBuild) command).
New: Create a new .NET project or file (create a new .NET project or file).
Nuget: Provides additional NuGet commands (provides other NuGet commands).
Pack: Create a NuGet package (create a NuGet package).
Publish: Publish a .NET project for deployment (publishes a .NET project for deployment).
Remove: Remove a package or reference from a .NET project (remove a package or reference from a .NET project).
Restore: Restore dependencies specified in a .NET project (restore the dependencies specified in the .NET project).
Run: Build and run a .NET project output (build and run .NET project output).
Sln: Modify Visual Studio solution files (modify Visual Studio solution file).
Store: Store the specified assemblies in the runtime package store (stores the specified assembly in the runtime package store).
Test: Run unit tests using the test runner specified in a .NET project (run unit tests using the test runner specified in the. Net project).
Tool: Install or manage tools that extend the .NET experience (installing or managing tools that extend the .NET experience).
Vstest: Run Microsoft Test Engine (VSTest) commands (run the Microsoft Test engine (VSTest) command)
Project modification command
Add package: Adds a package reference to a project. (add a package reference to the project.)
Add reference: Adds project-to-project (P2P) references. (add inter-project reference (P2P).)
Remove package: Removes package reference from the project. (remove the package reference from the project.)
Remove reference: Removes project reference. (delete project reference.)
List reference: Lists all project-to-project references. (list all inter-project references.)
Advanced command
Nuget delete: Deletes or un-lists a package from the server. (remove or unlist packages from the server.)
Nuget locals: Clear or lists NuGet resources. (clear or list NuGet resources.)
Nuget push: Pushes a package to the server and publishes it. (push the package to the server and publish it.)
Msbuild: Builds a project and all of its dependencies. (build the project and all its dependencies.)
Dotnet install script: Script used to install .NET Core CLI tools and the shared runtime.
(scripts for installing .NET Core CLI tools and sharing the runtime)
(scripts for installing .NET Core CLI tools and sharing the runtime)
Create a new project using the .NET Core CLI command
Let's create, restore, build, and run the. NET Core console application using the command line interface without using Visual Studio. To create a new .NET Core project, we must use the "new" command and the template name parameter. We can use CLI to create console, class library, Web,WebApp,MVC,WebAPI,react,Angular,React and other projects.
The following command creates a new dotnet core project using TEMPLATE:
Dotnet new
You can find the list of templates using the following methods:
Dotnet new-l
When you type dotnet new-l and press Enter, it displays a list of available templates based on the version of .NET Core installed on the machine, as shown in the following figure:
Example: create a console application using .NET Core CLI
The following command creates a new console project in the current directory with the same name as the current directory.
C:\ Users\ zhouh\ Desktop\ MyApp > dotnet new console
Once the above command is executed, it will create a console application, and you will get the following output.
Run the project using the .NET CLI command
To run the .NET Core project, we need to use the "dotnet run" command, as follows: here, you can see that it displays the output Hello World!
Generate a project using the .NET core CLI command
In order to build a new or existing project, we need to build your .NET Core project using the following "dotnet build" command:
This is the end of the introduction to "how to use the ASP.NET Core command line interface CLI". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.