zoukankan      html  css  js  c++  java
  • .NET CORE实践(1)--Ubuntu下的Hello World

    准备工作

    • 使用Hyper-V安装Ubuntu16.04桌面版
      因为是作为类似日记的记录,所以写的时候事无巨细,稍显啰嗦。
      打开微软.NET官网

    官网截图


    apt-get install

    打开dotnetcore ubuntu

    截图2
    按照官网步骤

    1、Add the dotnet apt-get feed

    In order to install .NET Core on Ubuntu or Linux Mint, we need to first set up the apt-get feed that hosts the package we need.

    For Ubuntu 14.04 or Linux Mint 17, run the following commands

    1 a@a-Virtual-Machine:~$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
    2 
    3 a@a-Virtual-Machine:~$ sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    4 
    5 a@a-Virtual-Machine:~$ sudo apt-get update

    For Ubuntu 16.04, run the following commands

    1 a@a-Virtual-Machine:~$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
    2 
    3 a@a-Virtual-Machine:~$ sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    4 
    5 a@a-Virtual-Machine:~$ sudo apt-get update

    2、 Install .NET Core SDK

    Before you start, please remove any previous versions of .NET Core from your system by using this script.

    To .NET Core on Ubuntu or Linux Mint, simply use apt-get.

     1 a@a-Virtual-Machine:~$ sudo apt-get install dotnet-dev-1.0.0-preview2-003121 

    3、Initialize some code

    Let’s initialize a sample Hello World application!

    1 a@a-Virtual-Machine:~$ mkdir hwapp 
    2 a@a-Virtual-Machine:~$ cd hwapp
    3 a@a-Virtual-Machine:~$ dotnet new
     

    执行dotnet new之后,查看文件目录

    a@a-Virtual-Machine:~/hwapp$ dotnet new
    Created new C# project in /home/a/hwapp.
    a@a-Virtual-Machine:~/hwapp$ ls
    Program.cs  project.json
    a@a-Virtual-Machine:~/hwapp$ 

    4、Run the app

    The first command will restore the packages specified in the project.json file, and the second command will run the actual sample:

    a@a-Virtual-Machine:~/hwapp$ dotnet restore
    a@a-Virtual-Machine:~/hwapp$ dotnet run

    执行dotnet restore

    a@a-Virtual-Machine:~/hwapp$ dotnet restore
    log  : Restoring packages for /home/a/hwapp/project.json...
    log  : Writing lock file to disk. Path: /home/a/hwapp/project.lock.json
    log  : /home/a/hwapp/project.json
    log  : Restore completed in 1759ms.
    a@a-Virtual-Machine:~/hwapp$ ls -o
    总用量 288
    -rwxrw-r-- 1 a    202 6月   7 02:37 Program.cs
    -rwxrw-r-- 1 a    348 6月  22 03:06 project.json
    -rwxrw-r-- 1 a 283977 7月  19 14:43 project.lock.json

    执行dotnet run

    a@a-Virtual-Machine:~/hwapp$ dotnet run
    Project hwapp (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
    Compiling hwapp for .NETCoreApp,Version=v1.0
    
    Compilation succeeded.
        0 Warning(s)
        0 Error(s)
    
    Time elapsed 00:00:02.4613028
    
    
    Hello World!
    a@a-Virtual-Machine:~/hwapp$ ls -o
    总用量 296
    drwxrwxr-x 3 a   4096 7月  19 14:44 bin
    drwxrwxr-x 3 a   4096 7月  19 14:44 obj
    -rwxrw-r-- 1 a    202 6月   7 02:37 Program.cs
    -rwxrw-r-- 1 a    348 6月  22 03:06 project.json
    -rwxrw-r-- 1 a 283977 7月  19 14:43 project.lock.json
  • 相关阅读:
    <QT学习>串口QSerialPort类同步与异步接收和发送数据
    <QT学习>QT生成与调用共享库
    《Pinctrl和GPIO子系统的使用》
    《查询方式的按键驱动程序》
    《C库 — sprintf字符串格式化命令,把格式化的数据写入某个字符串中》
    《C库 — 字符串合并函数strcat 字符串常量导致程序崩溃》
    Ex 5_22 在此我们基于以下性质给出一个新的最小生成树算法..._第九次作业
    Ex 5_21 无向图G=(V,E)的反馈边集..._第九次作业
    Ex 5_33 实现一个关于公式长度(其中所有文字总的出现次数)为线性时间的Horn公式可满足性问题_第十次作业
    Ex 5_28 Alice想要举办一个舞会..._第十次作业
  • 原文地址:https://www.cnblogs.com/AlienXu/p/6875964.html
Copyright © 2011-2022 走看看