天天看點

Windows 下開發.NET Core應用

一、使用Visual Studio 2015開發

1.1 依次安裝

Visual Studio 2015 Update 3

.NET Core 1.0.0 - VS 2015 Tooling Preview 2

1.2 IDE中建立.NET Core項目,使用Nuget管理器,這些大家就都熟悉啦

1.3 釋出應用,寫好的程式要釋出到伺服器上這是必需的

解決方案管理器》要釋出項目》右鍵》釋出》選擇檔案系統,就會釋出到本地的bin\Debug\PublishOutput目錄啦

二、使用指令行方式開發

如果覺得前一種方式不爽,不想安裝那麼大的VS2015,那就用這種方式吧

2.1 安裝.NET Core SDK for Windows和Visual Studio Code(以下簡稱Code)

2.2 使用指令行建立一個項目

mkdir HelloWorldApp

cd HelloWorldApp

dotnet new

2.3 打開Code,安裝C#擴充,打開HelloWorldApp目錄,對C#代碼進行編輯

2.3 編譯運作

::恢複Nuget包

dotnet restore

::編譯運作

dotnet run

2.4 釋出

dotnet publish

附:dotnet指令(全名:Microsoft .NET Core Shared Framework Host)

C:\>dotnet --help

.NET Command Line Tools (1.0.0-preview2-003121)

Usage: dotnet [host-options] [command] [arguments] [common-options]

Arguments:

[command] The command to execute

[arguments] Arguments to pass to the command

[host-options] Options specific to dotnet (host)

[common-options] Options common to all commands

Common options:

-v|--verbose Enable verbose output

-h|--help Show help

Host options (passed before the command):

--version Display .NET CLI Version Number

--info Display .NET CLI Info

Common Commands:

new Initialize a basic .NET project

restore Restore dependencies specified in the .NET project

build Builds a .NET project

publish Publishes a .NET project for deployment (including the runtime)

run Compiles and immediately executes a .NET project

test Runs unit tests using the test runner specified in the project

pack Creates a NuGet package