文章目錄
  1. 1. install Visual Studio Code
  2. 2. install .NET
    1. 2.1. Add the dotnet product feed
    2. 2.2. Install .NET SDK
    3. 2.3. Create your app
    4. 2.4. Run your app
    5. 2.5. 常用命令
  3. 3. 参考文献

在ubuntu中.NET简单的环境配置。文章基本翻译自 Get started with .NET in 10 minutes

install Visual Studio Code

  • 下载Visual Studio Code。下载链接
  • 安装。 sudo dpkg -i code_1.19.2-1515599945_amd64.deb
  • 打开Visual Studio Code, install C#

install .NET

Add the dotnet product feed

注册授信任的Microsoft签名密匙

1
2
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

注册Microsoft产品
Ubuntu 17.10

1
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > /etc/apt/sources.list.d/dotnetdev.list'

Ubuntu 17.04

1
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-zesty-prod zesty main" > /etc/apt/sources.list.d/dotnetdev.list'

Ubuntu 16.04 / Linux Mint 18

1
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

Install .NET SDK

更新软件源,然后安装

1
2
3
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1.4

Create your app

1
2
dotnet new console -o myApp
cd myApp

dotnet命令将会创建一个新的console应用。参数-o将会创建一个名字为myApp的目录,并且创建一些必要的此应用的文件。主文件是Program.cs.

Run your app

1
dotnet run

常用命令

  • 查看帮助 dotnet --help
  • 查看.NET为我们提供了什么样的项目模板 dotnet new -l
  • 创建模板
    1
    dotnet new <TEMPLATE> [--force] [-i|--install] [-lang|--language] [-n|--name] [-o|--output] [-u|--uninstall] [Template options]

参考文献

Get started with .NET in 10 minutes
dotnet new

文章目錄
  1. 1. install Visual Studio Code
  2. 2. install .NET
    1. 2.1. Add the dotnet product feed
    2. 2.2. Install .NET SDK
    3. 2.3. Create your app
    4. 2.4. Run your app
    5. 2.5. 常用命令
  3. 3. 参考文献