Open3

Blazor WebAssembly Hosted を自前で。

ynakayamaynakayama
$app = "BlazorHosted"
mkdir $app
cd $app
dotnet new sln --name $app
dotnet new webapi --output .\src\$app.Web --framework net5.0 --auth None --no-openapi false
dotnet new blazorwasm --output .\src\$app.Client --framework net5.0 --auth None
dotnet new classlib --output .\src\$app.Shared --framework net5.0
dotnet sln add .\src\$app.Web\$app.Web.csproj --solution-folder src
dotnet sln add .\src\$app.Client\$app.Client.csproj --solution-folder src
dotnet sln add .\src\$app.Shared\$app.Shared.csproj --solution-folder src
dotnet add .\src\$app.Web\$app.Web.csproj reference .\src\$app.Client\$app.Client.csproj
dotnet add .\src\$app.Web\$app.Web.csproj reference .\src\$app.Shared\$app.Shared.csproj
dotnet add .\src\$app.Client\$app.Client.csproj reference .\src\$app.Shared\$app.Shared.csproj
ynakayamaynakayama

BlazorHosted\src\BlazorHosted.Client\Properties\launchSettings.json の中身を BlazorHosted\src\BlazorHosted.Web\Properties\launchSettings.json に丸ごとコピー。

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:34293",
      "sslPort": 44325
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "BlazorHosted.Client": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

ynakayamaynakayama

あとは Hosted と比較してパッケージ追加と Startup.cs を修正すれば OK!(手抜き)