2017年6月1日 星期四

[.Net Core] dotnet commands


 .NET Core   dotnet CLI   


Basic


Add --help on the following commands for more information.

dotnet new

Install project template pack

$ dotnet new –install|[-i] <template name>

Or uninstall

$ dotnet new –uninstall|[-u] <template name>



See all project templates

$ dotnet new --list


Create new project

$ dotnet new <project template name> [--name] 

For example,
dotnet new mvc --name JB.Sample.Mvc



dotnet sln

Create a new solution file

dotnet new sln --name <solution file name (without .sln)>


For example,

dotnet new sln --name MyDemo 



Add a project to solution

$ dotnet sln [solution file path] add <project name>.csproj



For example,

dotnet sln add MyDemo/MyDemo.csproj 

Or

dotnet sln MyDemo.sln add MyDemo/MyDemo.csproj



Remove a project from solution

$ dotnet sln remove <project name>.csproj


See projects which are included in the solution

$ dotnet sln list




dotnet restore

$ dotnet restore


dotnet build

$ dotnet build


Build with specific configuration

$ dotnet build --configuration Release


Build with specific configuration

$ dotnet build --framework netcoreapp3.1



Project modification



package

Add package

$ dotnet add package <package name> [--version]

For example,
dotnet add package System.Data.SqlClient --version 4.3.1

However, the package is installed as following,

<PackageReference Include="System.Data.SqlClient" Version="4.3.1" />

And currently NOT SUPPORT installing a tool reference. For example, what we expected for adding a tool package,

<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview1-final" />

Follow nuget issue #4190 for a update in the near future.



Remove package

$ dotnet remove package <package name>




Reference


Add reference

$ dotnet add reference <related path>\<project name>.csproj

For example,
dotnet add reference ..\JB.Sample.Core.csproj


Remove reference

$ dotnet remove reference <related path>\<project name>.csproj



List all reference

$ dotnet list reference






dotnet tool




dotnet-ef

Install

$ dotnet tool install --global dotnet-ef


Upgrade

$ dotnet tool update --global dotnet-ef


See version

$ dotnet tool --version




Reference




沒有留言:

張貼留言