ハロの外部記憶インターフェイス

そろそろ覚える努力が必要かも…

.Net CoreをUbuntuに入れてみた。

apt-getのソースリストにdotnetdev.listを追加する。

parallels@ubuntu:~$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
[sudo] password for parallels: 
parallels@ubuntu:~$ sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.GTj2NFsQe2 --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
gpg: requesting key 417A0893 from hkp server apt-mo.trafficmanager.net
gpg: key 417A0893: public key "MS Open Tech <interop@microsoft.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
parallels@ubuntu:~$ sudo apt-get update

.net core 1.0 preview2バージョンのインストール

parallels@ubuntu:~$ sudo apt-get install dotnet-dev-1.0.0-preview2-003121
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  dotnet-host dotnet-hostfxr-1.0.1
  dotnet-sharedframework-microsoft.netcore.app-1.0.0 liblldb-3.6 libllvm3.6
  liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu1
The following NEW packages will be installed:
  dotnet-dev-1.0.0-preview2-003121 dotnet-host dotnet-hostfxr-1.0.1
  dotnet-sharedframework-microsoft.netcore.app-1.0.0 liblldb-3.6 libllvm3.6
  liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu1
0 upgraded, 10 newly installed, 0 to remove and 28 not upgraded.
Need to get 54.9 MB of archives.
After this operation, 169 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty-updates/main libllvm3.6 amd64 1:3.6-2ubuntu1~trusty1 [7,858 kB]
Get:2 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty-updates/main liblldb-3.6 amd64 1:3.6-2ubuntu1~trusty1 [7,055 kB]
Get:3 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty/main libunwind8 amd64 1.1-2.2ubuntu3 [48.3 kB]
Get:4 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty/main liburcu1 amd64 0.7.12-0ubuntu2 [34.9 kB]
Get:5 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty/main liblttng-ust-ctl2 amd64 2.4.0-4ubuntu1 [61.7 kB]
Get:6 http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ trusty/main liblttng-ust0 amd64 2.4.0-4ubuntu1 [106 kB]
Fetched 54.9 MB in 1min 6s (830 kB/s)                                          
Selecting previously unselected package libllvm3.6:amd64.
(Reading database ... 197381 files and directories currently installed.)
Preparing to unpack .../libllvm3.6_1%3a3.6-2ubuntu1~trusty1_amd64.deb ...
Unpacking libllvm3.6:amd64 (1:3.6-2ubuntu1~trusty1) ...
Selecting previously unselected package liblldb-3.6.
Preparing to unpack .../liblldb-3.6_1%3a3.6-2ubuntu1~trusty1_amd64.deb ...
Unpacking liblldb-3.6 (1:3.6-2ubuntu1~trusty1) ...
Selecting previously unselected package libunwind8.
Preparing to unpack .../libunwind8_1.1-2.2ubuntu3_amd64.deb ...
Unpacking libunwind8 (1.1-2.2ubuntu3) ...
Selecting previously unselected package liburcu1.
Preparing to unpack .../liburcu1_0.7.12-0ubuntu2_amd64.deb ...
Unpacking liburcu1 (0.7.12-0ubuntu2) ...
Selecting previously unselected package liblttng-ust-ctl2:amd64.
Preparing to unpack .../liblttng-ust-ctl2_2.4.0-4ubuntu1_amd64.deb ...
Unpacking liblttng-ust-ctl2:amd64 (2.4.0-4ubuntu1) ...
Selecting previously unselected package liblttng-ust0:amd64.
Preparing to unpack .../liblttng-ust0_2.4.0-4ubuntu1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.4.0-4ubuntu1) ...
Selecting previously unselected package dotnet-host.
Preparing to unpack .../dotnet-host_1.0.1-1_amd64.deb ...
Unpacking dotnet-host (1.0.1-1) ...
Selecting previously unselected package dotnet-hostfxr-1.0.1.
Preparing to unpack .../dotnet-hostfxr-1.0.1_1.0.1-1_amd64.deb ...
Unpacking dotnet-hostfxr-1.0.1 (1.0.1-1) ...
Selecting previously unselected package dotnet-sharedframework-microsoft.netcore.app-1.0.0.
Preparing to unpack .../dotnet-sharedframework-microsoft.netcore.app-1.0.0_1.0.0-1_amd64.deb ...
Unpacking dotnet-sharedframework-microsoft.netcore.app-1.0.0 (1.0.0-1) ...
Selecting previously unselected package dotnet-dev-1.0.0-preview2-003121.
Preparing to unpack .../dotnet-dev-1.0.0-preview2-003121_1.0.0-preview2-003121-1_amd64.deb ...
Unpacking dotnet-dev-1.0.0-preview2-003121 (1.0.0-preview2-003121-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libllvm3.6:amd64 (1:3.6-2ubuntu1~trusty1) ...
Setting up liblldb-3.6 (1:3.6-2ubuntu1~trusty1) ...
Setting up libunwind8 (1.1-2.2ubuntu3) ...
Setting up liburcu1 (0.7.12-0ubuntu2) ...
Setting up liblttng-ust-ctl2:amd64 (2.4.0-4ubuntu1) ...
Setting up liblttng-ust0:amd64 (2.4.0-4ubuntu1) ...
Setting up dotnet-host (1.0.1-1) ...
Setting up dotnet-hostfxr-1.0.1 (1.0.1-1) ...
Setting up dotnet-sharedframework-microsoft.netcore.app-1.0.0 (1.0.0-1) ...
Setting up dotnet-dev-1.0.0-preview2-003121 (1.0.0-preview2-003121-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...

Hellow World appを実行してみる

parallels@ubuntu:~$ mkdir hwapp
parallels@ubuntu:~$ cd hwapp
parallels@ubuntu:~/hwapp$ dotnet new

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 2676 ms
Expanding 100% 41298 ms
Created new C# project in /home/parallels/hwapp.
parallels@ubuntu:~/hwapp$ ls
Program.cs  project.json
parallels@ubuntu:~/hwapp$ cat Program.cs
using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
parallels@ubuntu:~/hwapp$ cat project.json
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      },
      "imports": "dnxcore50"
    }
  }
}

ソースをコンパイルし実行する。

dotnet restore は

parallels@ubuntu:~/hwapp$ dotnet restore
log  : Restoring packages for /home/parallels/hwapp/project.json...
log  : Writing lock file to disk. Path: /home/parallels/hwapp/project.lock.json
log  : /home/parallels/hwapp/project.json
log  : Restore completed in 1327ms.
parallels@ubuntu:~/hwapp$ ls
Program.cs  project.json  project.lock.json
parallels@ubuntu:~/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:01.5571249
 

Hello World!

dotnetの各命令

dotnet new : サンプル プロジェクトの生成 (C#, F#)
dotnet restore : 実行に必要なパッケージのリストア
dotnet build : .NET Core プロジェクトのビルド
dotnet publish : .NET アプリケーションの発行
dotnet run : .NET プロジェクトのビルドと実行
dotnet test : ユニットテストの実行
dotnet pack : アセンブリの NuGet パッケージ生成
dotnet [app.dll] : アプリケーションの実行