diff --git a/.github/workflows/azure-static-web-apps-brave-stone-0645cc000.yml b/.github/workflows/azure-static-web-apps-brave-stone-0645cc000.yml index bf06ff9..1dd5823 100644 --- a/.github/workflows/azure-static-web-apps-brave-stone-0645cc000.yml +++ b/.github/workflows/azure-static-web-apps-brave-stone-0645cc000.yml @@ -18,6 +18,8 @@ jobs: - uses: actions/checkout@v4.1.1 with: submodules: true + - name: Install wasm-tools + run: dotnet workload install wasm-tools - name: Build And Deploy id: builddeploy uses: Azure/static-web-apps-deploy@v1 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 044ec48..5bfb8e9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,10 +41,10 @@ jobs: - name: 🛒 Checkout repository uses: actions/checkout@v4.1.1 - - name: ✨ Setup .NET 7.0 + - name: ✨ Setup .NET 8.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x # Initializes the CodeQL tools for scanning. - name: ✨ Initialize CodeQL diff --git a/.github/workflows/deploy-to-ghpages.yml b/.github/workflows/deploy-to-ghpages.yml index 50734ef..c115247 100644 --- a/.github/workflows/deploy-to-ghpages.yml +++ b/.github/workflows/deploy-to-ghpages.yml @@ -10,7 +10,7 @@ on: env: CONFIGURATION: Release - DOTNET_CORE_VERSION: 7.0.x + DOTNET_VERSION: 8.0.x WORKING_DIRECTORY: TryAzureStaticBlazorApp jobs: @@ -22,7 +22,9 @@ jobs: - name: ✨ Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: ${{ env.DOTNET_CORE_VERSION }} + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: ⚙️ Install wasm-tools + run: dotnet workload install wasm-tools - name: 🚚 Restore run: dotnet restore "${{ env.WORKING_DIRECTORY }}" - name: 🛠️ Build diff --git a/README.md b/README.md index 7bd1077..c013614 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ Blazor wasm アプリを次のホスティングサービスへデプロイし * [Azure Static Web Apps (https://brave-stone-0645cc000.2.azurestaticapps.net/)](https://brave-stone-0645cc000.2.azurestaticapps.net/) * [GitHub Pages (https://maremare.github.io/try-deploy-blazor-wasm-app/)](https://maremare.github.io/try-deploy-blazor-wasm-app/) * [Cloudflare Pages (https://try-deploy-blazor-wasm-app.pages.dev/)](https://try-deploy-blazor-wasm-app.pages.dev/) - * [Cloudflare Pages (https://wasm2.trypage.tk/)](https://wasm2.trypage.tk/) ## 前提条件 * Azure アカウント * GitHub アカウント +* Cloudflare アカウント ## アプリケーションの作成 @@ -203,7 +203,7 @@ GitHub Pages へ発行するには次の調整が必要になるらしい。 * `404.html` の追加 この煩わしい調整を -[NuGet Gallery \| PublishSPAforGitHubPages\.Build 2\.0\.1](https://www.nuget.org/packages/PublishSPAforGitHubPages.Build/#readme-body-tab) という素晴らしいパッケージを利用すると自動化してくれる。 +[NuGet Gallery \| PublishSPAforGitHubPages\.Build](https://www.nuget.org/packages/PublishSPAforGitHubPages.Build/#readme-body-tab) という素晴らしいパッケージを利用すると自動化してくれる。 使い方は次の通り: 1. `PublishSPAforGitHubPages.Build` Nuget パッケージ参照を追加 @@ -255,7 +255,7 @@ on: env: CONFIGURATION: Release - DOTNET_CORE_VERSION: 6.0.x + DOTNET_VERSION: 8.0.x WORKING_DIRECTORY: TryAzureStaticBlazorApp jobs: @@ -263,11 +263,13 @@ jobs: runs-on: ubuntu-latest steps: - name: 🛒 Checkout - uses: actions/checkout@master - - name: ✨ Setup .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/checkout@v4.1.1 + - name: ✨ Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: ${{ env.DOTNET_CORE_VERSION }} + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: ⚙️ Install wasm-tools + run: dotnet workload install wasm-tools - name: 🚚 Restore run: dotnet restore "${{ env.WORKING_DIRECTORY }}" - name: 🛠️ Build @@ -297,15 +299,23 @@ deploy ```sh curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh; chmod +x dotnet-install.sh; - ./dotnet-install.sh -c 7.0 -InstallDir ./dotnet7; - ./dotnet7/dotnet --version; - ./dotnet7/dotnet publish "src/blazorwasm-standalone-singleOrg" -c Release -o output; + ./dotnet-install.sh -c 8.0 -InstallDir ./dotnet8; + ./dotnet8/dotnet --version; + ./dotnet8/dotnet workload install wasm-tools; + ./dotnet8/dotnet publish "TryAzureStaticBlazorApp" -c Release -o output; ``` * ビルド出力ディレクトリ ```sh /output/wwwroot ``` +## Run Blazor Web Assembly locally +* [natemcmaster/dotnet\-serve: Simple command\-line HTTPS server for the \.NET Core CLI](https://github.com/natemcmaster/dotnet-serve) + ```ps1 + dotnet publish TryAzureStaticBlazorApp -c release -o publish + dotnet serve -o -S -p:7014 -b -d:publish/wwwroot + ``` + ## 参考サイト * [チュートリアル:Azure Static Web Apps での Blazor を使用した静的 Web アプリのビルド \| Microsoft Docs](https://docs.microsoft.com/ja-jp/azure/static-web-apps/deploy-blazor?WT.mc_id=-blog-scottha) * [Azure Static Web Apps with \.NET and Blazor \| ASP\.NET Blog](https://devblogs.microsoft.com/aspnet/azure-static-web-apps-with-blazor/) diff --git a/TryAzureStaticBlazorApp/Shared/MainLayout.razor b/TryAzureStaticBlazorApp/Layout/MainLayout.razor similarity index 75% rename from TryAzureStaticBlazorApp/Shared/MainLayout.razor rename to TryAzureStaticBlazorApp/Layout/MainLayout.razor index 839b8fe..76eb725 100644 --- a/TryAzureStaticBlazorApp/Shared/MainLayout.razor +++ b/TryAzureStaticBlazorApp/Layout/MainLayout.razor @@ -1,5 +1,4 @@ @inherits LayoutComponentBase -
This component demonstrates fetching data from the server.
@@ -46,7 +46,7 @@ else public class WeatherForecast { - public DateTime Date { get; set; } + public DateOnly Date { get; set; } public int TemperatureC { get; set; } diff --git a/TryAzureStaticBlazorApp/Properties/launchSettings.json b/TryAzureStaticBlazorApp/Properties/launchSettings.json index c63a224..6cb8b25 100644 --- a/TryAzureStaticBlazorApp/Properties/launchSettings.json +++ b/TryAzureStaticBlazorApp/Properties/launchSettings.json @@ -1,19 +1,30 @@ { + "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:37435", - "sslPort": 44355 + "applicationUrl": "http://localhost:36586", + "sslPort": 44334 } }, "profiles": { - "TryAzureStaticBlazorApp": { + "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "https://localhost:7169;http://localhost:5169", + "applicationUrl": "http://localhost:5025", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7014;http://localhost:5025", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/TryAzureStaticBlazorApp/Shared/NavMenu.razor.css b/TryAzureStaticBlazorApp/Shared/NavMenu.razor.css deleted file mode 100644 index acc5f9f..0000000 --- a/TryAzureStaticBlazorApp/Shared/NavMenu.razor.css +++ /dev/null @@ -1,62 +0,0 @@ -.navbar-toggler { - background-color: rgba(255, 255, 255, 0.1); -} - -.top-row { - height: 3.5rem; - background-color: rgba(0,0,0,0.4); -} - -.navbar-brand { - font-size: 1.1rem; -} - -.oi { - width: 2rem; - font-size: 1.1rem; - vertical-align: text-top; - top: -2px; -} - -.nav-item { - font-size: 0.9rem; - padding-bottom: 0.5rem; -} - - .nav-item:first-of-type { - padding-top: 1rem; - } - - .nav-item:last-of-type { - padding-bottom: 1rem; - } - - .nav-item ::deep a { - color: #d7d7d7; - border-radius: 4px; - height: 3rem; - display: flex; - align-items: center; - line-height: 3rem; - } - -.nav-item ::deep a.active { - background-color: rgba(255,255,255,0.25); - color: white; -} - -.nav-item ::deep a:hover { - background-color: rgba(255,255,255,0.1); - color: white; -} - -@media (min-width: 641px) { - .navbar-toggler { - display: none; - } - - .collapse { - /* Never collapse the sidebar for wide screens */ - display: block; - } -} diff --git a/TryAzureStaticBlazorApp/Shared/SurveyPrompt.razor b/TryAzureStaticBlazorApp/Shared/SurveyPrompt.razor deleted file mode 100644 index 962027f..0000000 --- a/TryAzureStaticBlazorApp/Shared/SurveyPrompt.razor +++ /dev/null @@ -1,16 +0,0 @@ -