次のバージョンで確認しました。
$ dotnet --version
6.0.302
こちらで作成したプロジェクトを publish する方法
です。
Raspberry Pi で .Net Core の Web アプリケーションを作成
1: appsettings.json の修正
localhost 以外からもアクセスできるようにする。
appsettings.json
{
"urls": "http://*:5000",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
2: publish (bin/Release 以下にリリース版を作成)
$ dotnet publish -c Release
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
Web01 -> /home/uchida/tmp/Web01/bin/Release/net6.0/Web01.dll
Web01 -> /home/uchida/tmp/Web01/bin/Release/net6.0/publish/
3: Kestrel サーバーを実行
$ dotnet bin/Release/net6.0/Web01.dll
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/uchida/tmp/Web01/
4: ブラウザーで http://host:5000/ にアクセス