2.2. .NET Core 2.1 を使用したアプリケーションの作成
C# hello-world アプリケーションを作成する方法を学びます。
手順
my-appという名前のディレクトリーに、新しい Console アプリケーションを作成します。$ dotnet new console --output my-app返される出力は以下のとおりです。
The template "Console Application" was created successfully. Processing post-creation actions... Running 'dotnet restore' on my-app/my-app.csproj... Restoring packages for /home/username/my-app/my-app.csproj... Generating MSBuild file /home/username/my-app/obj/my-app.csproj.nuget.g.props. Generating MSBuild file /home/username/my-app/obj/my-app.csproj.nuget.g.targets. Restore completed in 224.85 ms for /home/username/my-app/my-app.csproj. Restore succeeded.
単純な
Hello Worldコンソールアプリケーションが、テンプレートから作成されます。アプリケーションは指定のmy-appディレクトリーに保存されます。ディレクトリーには、以下のファイルが含まれます。
$ tree my-app my-app ├── my-app.csproj ├── obj │ ├── my-app.csproj.nuget.dgspec.json │ ├── my-app.csproj.nuget.g.props │ ├── my-app.csproj.nuget.g.targets │ ├── project.assets.json │ └── project.nuget.cache └── Program.cs 1 directory, 7 files
検証手順
プロジェクトを実行します。
$ dotnet run --project my-app返される出力は以下のとおりです。
Hello World!