dotnet 命令的使用

dotnet --info

PS E:\GitHub\KerryJiang\SuperSocket> dotnet --info
.NET Command Line Tools (2.1.4)

Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190

Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.4\

Microsoft .NET Core Shared Framework Host

Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54

 

 

dotnet new console -o hwapp

dotnet restore

dotnet run

 

 

dotnet new 

        Creates a new project, configuration file, or solution based on the specified template.

Description

The dotnet new command provides a convenient way to initialize a valid .NET Core project.

The command calls the template engine to create the artifacts on disk based on the specified template and options.

 

 

dotnet restore

       Restores the dependencies and tools of a project.

Description

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. By default, the restoration of dependencies and tools are performed in parallel.

 

In order to restore the dependencies, NuGet needs the feeds where the packages are located.

Feeds are usually provided via the NuGet.config configuration file.

A default configuration file is provided when the CLI tools are installed.

You specify additional feeds by creating your own NuGet.config file in the project directory.

You also specify additional feeds per invocation at a command prompt.

 

For dependencies, you specify where the restored packages are placed during the restore operation using the --packages argument.

If not specified, the default NuGet package cache is used, which is found in the .nuget/packages directory in the user's home directory on all operating systems (for example, /home/user1 on Linux or C:\Users\user1 on Windows).

 

For project-specific tooling, dotnet restore first restores the package in which the tool is packed, and then proceeds to restore the tool's dependencies as specified in its project file.

 

The behavior of the dotnet restore command is affected by some of the settings in the Nuget.Config file, if present.

For example, setting the globalPackagesFolder in NuGet.Config places the restored NuGet packages in the specified folder.

This is an alternative to specifying the --packages option on the dotnet restore command.

For more information, see the NuGet.Config reference.

 

异常处理

PS D:\ChuckLu\Git\GitHub\KerryJiang\IrvineCSharpCourses> dotnet restore
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

这个命令需要在项目或者解决方案下运行才有效

 

dotnet run

     Runs source code without any explicit compile or launch commands.

Description

The dotnet run command provides a convenient option to run your application from the source code with one command.

It's useful for fast iterative development from the command line.

The command depends on the dotnet build command to build the code.

Any requirements for the build, such as that the project must be restored first, apply to dotnet run as well.

 

Output files are written into the default location, which is bin/<configuration>/<target>.

For example if you have a netcoreapp1.0 application and you run dotnet run, the output is placed in bin/Debug/netcoreapp1.0.

Files are overwritten as needed.

Temporary files are placed in the obj directory.

 

If the project specifies multiple frameworks, executing dotnet run results in an error unless the -f|--framework <FRAMEWORK> option is used to specify the framework.

 

The dotnet run command is used in the context of projects, not built assemblies. If you're trying to run a framework-dependent application DLL instead, you must use dotnet without a command. For example, to run myapp.dll, use:

 
dotnet myapp.dll

For more information on the dotnet driver, see the .NET Core Command Line Tools (CLI) topic.

 

In order to run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production. Instead, create a deployment using the dotnet publish command and deploy the published output. 

 

 

dotnet --version

PS E:\GitHub\KerryJiang\SuperSocket> dotnet sln .\SuperSocket.sln list
Project reference(s)
--------------------
src\SuperSocket.Primitives\SuperSocket.Primitives.csproj
src\SuperSocket.ProtoBase\SuperSocket.ProtoBase.csproj
src\SuperSocket.NetSocket\SuperSocket.NetSocket.csproj
src\SuperSocket.Libuv\SuperSocket.Libuv.csproj
test
test\Test\Test.csproj
src\SuperSocket.Server\SuperSocket.Server.csproj
src\SuperSocket.Channel\SuperSocket.Channel.csproj

 

-v|--verbosity <LEVEL>

Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].

 

 

 

 

 

posted @ 2017-06-29 18:42  ChuckLu  阅读(4072)  评论(0编辑  收藏  举报