投げ銭

★当サイトへの投げ銭(PayPal)★

LINK


(無償、寄付歓迎) logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)

★LibreOfficeの導入事例★
詳細について

人気の投稿(1ヶ月間)

Ad

Ad

投げ銭

★当サイトへの投げ銭(PayPal)★

2017年8月31日木曜日

【Linux CentOS 7】.NET Core 2.0 SDK をインストールしてHelloWorldを表示するコンソールプログラムを実行した【.NET Core 2.0】

CentOS 7 64bitに、.NET Core 2.0 SDK を導入し、サンプルプログラムを実行した。
「参考」のリンクにあるページ通りに作業を行った。


■システムの更新

# yum update
# uname -a
Linux localhost.localdomain 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


■専用リポジトリを利用するための設定

# rpm --import https://packages.microsoft.com/keys/microsoft.asc

○repoファイルの生成
# sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'

# cat /etc/yum.repos.d/dotnetdev.repo
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc


■パッケージの導入(1)

# yum install libunwind libicu -y
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * ius: mirrors.tuna.tsinghua.edu.cn
 * nux-dextop: li.nux.ro
 * updates: ftp.tsukuba.wide.ad.jp
パッケージ libicu-50.1.2-15.el7.x86_64 はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ libunwind.x86_64 2:1.1-5.el7_2.2 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
========================================================================================================================================================================
 Package                                 アーキテクチャー                     バージョン                                       リポジトリー                        容量
========================================================================================================================================================================
インストール中:
 libunwind                               x86_64                               2:1.1-5.el7_2.2                                  base                                56 k
トランザクションの要約
========================================================================================================================================================================
インストール  1 パッケージ
総ダウンロード容量: 56 k
インストール容量: 146 k
Downloading packages:
libunwind-1.1-5.el7_2.2.x86_64.rpm                                                                                                               |  56 kB  00:00:00  
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : 2:libunwind-1.1-5.el7_2.2.x86_64                                                                                                        1/1
  検証中                  : 2:libunwind-1.1-5.el7_2.2.x86_64                                                                                                        1/1
インストール:
  libunwind.x86_64 2:1.1-5.el7_2.2                                                                                                                                    
完了しました!


■パッケージの導入(2)

yum install dotnet-sdk-2.0.0
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * ius: mirrors.tuna.tsinghua.edu.cn
 * nux-dextop: li.nux.ro
 * updates: ftp.tsukuba.wide.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ dotnet-sdk-2.0.0.x86_64 0:2.0.0-1 を インストール
--> 依存性の処理をしています: dotnet-runtime-2.0.0 >= 2.0.0 のパッケージ: dotnet-sdk-2.0.0-2.0.0-1.x86_64
--> 依存性の処理をしています: aspnetcore-store-2.0.0 >= 2.0.0 のパッケージ: dotnet-sdk-2.0.0-2.0.0-1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ aspnetcore-store-2.0.0.x86_64 0:2.0.0-1 を インストール
---> パッケージ dotnet-runtime-2.0.0.x86_64 0:2.0.0-1 を インストール
--> 依存性の処理をしています: dotnet-hostfxr-2.0.0 のパッケージ: dotnet-runtime-2.0.0-2.0.0-1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ dotnet-hostfxr-2.0.0.x86_64 0:2.0.0-1 を インストール
--> 依存性の処理をしています: dotnet-host >= 2.0.0 のパッケージ: dotnet-hostfxr-2.0.0-2.0.0-1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ dotnet-host.x86_64 0:2.0.0-1 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
========================================================================================================================================================================
 Package                                       アーキテクチャー              バージョン                        リポジトリー                                        容量
========================================================================================================================================================================
インストール中:
 dotnet-sdk-2.0.0                              x86_64                        2.0.0-1                           packages-microsoft-com-prod                         85 M
依存性関連でのインストールをします:
 aspnetcore-store-2.0.0                        x86_64                        2.0.0-1                           packages-microsoft-com-prod                         24 M
 dotnet-host                                   x86_64                        2.0.0-1                           packages-microsoft-com-prod                         42 k
 dotnet-hostfxr-2.0.0                          x86_64                        2.0.0-1                           packages-microsoft-com-prod                        181 k
 dotnet-runtime-2.0.0                          x86_64                        2.0.0-1                           packages-microsoft-com-prod                         24 M
トランザクションの要約
========================================================================================================================================================================
インストール  1 パッケージ (+4 個の依存関係のパッケージ)
総ダウンロード容量: 133 M
インストール容量: 133 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): dotnet-host-2.0.0-rhel.7-x64.rpm                                                                                                          |  42 kB  00:00:00  
(2/5): dotnet-hostfxr-2.0.0-rhel.7-x64.rpm                                                                                                       | 181 kB  00:00:00  
(3/5): aspnetcore-store-2.0.0-rhel.7-x64.rpm                                                                                                     |  24 MB  00:00:38  
(4/5): dotnet-runtime-2.0.0-rhel.7-x64.rpm                                                                                                       |  24 MB  00:00:46  
(5/5): dotnet-sdk-2.0.0-rhel-x64.rpm                                                                                                             |  85 MB  00:01:45  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                    949 kB/s | 133 MB  00:02:24  
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : aspnetcore-store-2.0.0-2.0.0-1.x86_64                                                                                                   1/5
  インストール中          : dotnet-host-2.0.0-1.x86_64                                                                                                              2/5
Creating dotnet host symbolic link: /usr/bin/dotnet
  インストール中          : dotnet-hostfxr-2.0.0-2.0.0-1.x86_64                                                                                                     3/5
  インストール中          : dotnet-runtime-2.0.0-2.0.0-1.x86_64                                                                                                     4/5
  インストール中          : dotnet-sdk-2.0.0-2.0.0-1.x86_64                                                                                                         5/5
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.
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.
.NET Core Tools Telemetry
--------------
The .NET Core Tools include a telemetry feature that collects usage information. It is important that the .NET Team understands how the tools are being used so that we can improve them.
The data collected is anonymous and will be published in an aggregated form for use by both Microsoft and community engineers under the Creative Commons Attribution License.
The .NET Core Tools telemetry feature is enabled by default. You can opt-out of the telemetry feature by setting an environment variable DOTNET_CLI_TELEMETRY_OPTOUT (for example, 'export' on macOS/Linux, 'set' on Windows) to true (for example, 'true', 1). You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry.
Installation Note
--------------
A command will be run during the install process that will improve project restore speed and enable offline access. It will take up to a minute to complete.
  検証中                  : dotnet-host-2.0.0-1.x86_64                                                                                                              1/5
  検証中                  : dotnet-sdk-2.0.0-2.0.0-1.x86_64                                                                                                         2/5
  検証中                  : dotnet-hostfxr-2.0.0-2.0.0-1.x86_64                                                                                                     3/5
  検証中                  : aspnetcore-store-2.0.0-2.0.0-1.x86_64                                                                                                   4/5
  検証中                  : dotnet-runtime-2.0.0-2.0.0-1.x86_64                                                                                                     5/5
インストール:
  dotnet-sdk-2.0.0.x86_64 0:2.0.0-1                                                                                                                                  
依存性関連をインストールしました:
  aspnetcore-store-2.0.0.x86_64 0:2.0.0-1      dotnet-host.x86_64 0:2.0.0-1      dotnet-hostfxr-2.0.0.x86_64 0:2.0.0-1      dotnet-runtime-2.0.0.x86_64 0:2.0.0-1  
完了しました!


■テストコンソールアプリケーションの生成と実行

# dotnet new console -o hwapp
.NET Core へようこそ!
---------------------
.NET Core について詳しくは、https://aka.ms/dotnet-docs をご覧ください。dotnet --help を使って使用可能なコマンドを確認するか、https://aka.ms/dotnet-cli-docs をご覧ください。
テレメトリ
--------------
.NET Core ツールは、操作性を向上させるために利用状況データを収集します。データは匿名で、コマンドライン引数が含まれません。データは Microsoft によって収集され、コミュニティと共有されます。
テレメトリを無効にするには、お好きなシェルを使用して、DOTNET_CLI_TELEMETRY_OPTOUT 環境変数を 1 に設定します。
.NET Core ツールのテレメトリについて詳しくは、https://aka.ms/dotnet-cli-telemetry をお読みください。
準備しています...
テンプレート "Console Application" が正常に作成されました。
作成後のアクションを処理しています...
'dotnet restore' を hwapp/hwapp.csproj で実行しています...
  Restoring packages for /home/myname/hwapp/hwapp.csproj...
  Generating MSBuild file /home/myname/hwapp/obj/hwapp.csproj.nuget.g.props.
  Generating MSBuild file /home/myname/hwapp/obj/hwapp.csproj.nuget.g.targets.
  Restore completed in 426.36 ms for /home/myname/hwapp/hwapp.csproj.

正常に復元されました。
# cd hwapp
# ls
Program.cs  hwapp.csproj  obj

以下のように、デフォルトで”Hello World”を表示するコードが書かれていた。
# cat Program.cs
using System;
namespace hwapp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
# cd obj/
# ls
hwapp.csproj.nuget.cache  hwapp.csproj.nuget.g.props  hwapp.csproj.nuget.g.targets  project.assets.json
# cd ..
# pwd
/home/myname/hwapp

プログラムを実行した。(起動するまでに10秒程度要した。)
# dotnet run
Hello World!


以上

ASP.NET MVCプログラミング入門 (マイクロソフト関連書)

新品価格
¥3,456から
(2018/5/21 15:43時点)



<参考>
・Install .NET and build your first app on CentOS or Oracle Linux
< https://www.microsoft.com/net/core#linuxcentos > 2017年8月30日

投げ銭

★当サイトへの投げ銭(PayPal)★

Ad

Ad