タイトルの通り、Visual Studio Code を利用して、ASP.NET Core Razor Pages アプリケーションを作成し、起動してみます。
アプリケーションの作成
コマンドプロンプトで、次のコマンドを実行して ASP.NET Core Razor Pages アプリケーションを作成します。
dotnet new webapp -o MyApp1
すると、次のようなメッセージが表示されます。
C:\Users\Administrator\Desktop>dotnet new webapp -o MyApp1 テンプレート "ASP.NET Core Web App" が正常に作成されました。 このテンプレートには、Microsoft 以外のパーティのテクノロジが含まれています。詳しくは、https://aka.ms/aspnetcore/6.0-third-party-notices をご覧ください。 作成後の操作を処理しています... C:\Users\Administrator\Desktop\MyApp1\MyApp1.csproj で ' dotnet restore ' を実行しています... 復元対象のプロジェクトを決定しています... C:\Users\Administrator\Desktop\MyApp1\MyApp1.csproj を復元しました (403 ms)。 正常に復元されました。
Visual Studio Code でアプリケーションを開く
続いて、コンソールで 'code MyApp1' を実行し、Visual Studio Code で作成したアプリケーションを開きます。
C:\Users\Administrator\Desktop>code MyApp1
アプリケーションの実行
Visual Studio Code のターミナルを開き(Ctrl + @)、'dotnet run' を実行してアプリケーションを実行します。
PS C:\Users\Administrator\Desktop\MyApp1> dotnet run
ビルドが始まり、アプリケーションが起動します。
PS C:\Users\Administrator\Desktop\MyApp1> dotnet run ビルドしています... info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7162 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5050 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Administrator\Desktop\MyApp1\
実行結果
上記ターミナルに記載されている「https://localhost:7162」にアクセスします。すると、アプリケーションが動作していることがわかります。
