From 7dd922d87f8ce90fc75e057ffe16c5688901e2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Kuklau?= Date: Tue, 19 Nov 2019 18:50:50 +0100 Subject: [PATCH 1/7] ManifestBaseURL/ServiceWorkerBaseURL was missing for some paths --- .../build/BlazorPWA.MSBuild.Manifest.targets | 2 +- .../build/BlazorPWA.MSBuild.ServiceWorker.targets | 2 +- .../build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets index 434766f..9bd8871 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets @@ -82,7 +82,7 @@ \ No newline at end of file diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index fad73ec..53552f6 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -105,7 +105,7 @@ + Lines="const requiredFiles = [;@(DistFiles -> '"/%(ServiceWorkerBaseURL)%(FileName)%(Extension)"'->Replace('\','/'),',%0D%0A');]%3B;" /> From b2d9429bd65a9a58da3db5f9e5b1e667404d5d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Kuklau?= Date: Thu, 21 Nov 2019 06:31:55 +0100 Subject: [PATCH 2/7] RecursiveDir needs to stay here --- .../build/BlazorPWA.MSBuild.ServiceWorker.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index 53552f6..fbfabbb 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -105,7 +105,7 @@ + Lines="const requiredFiles = [;@(DistFiles -> '"/%(ServiceWorkerBaseURL)%(RecursiveDir)%(FileName)%(Extension)"'->Replace('\','/'),',%0D%0A');]%3B;" /> Date: Thu, 21 Nov 2019 06:33:35 +0100 Subject: [PATCH 3/7] normalized casing of BaseUrl --- .../build/BlazorPWA.MSBuild.Manifest.targets | 2 +- .../build/BlazorPWA.MSBuild.ServiceWorker.targets | 6 +++--- .../build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets index 9bd8871..06b4b0b 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets @@ -82,7 +82,7 @@ \ No newline at end of file diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index fbfabbb..b8f4bce 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -49,7 +49,7 @@ - const baseURL = '$(ServiceWorkerBaseURL)'%3B; + const baseURL = '$(ServiceWorkerBaseUrl)'%3B; const indexURL = '$(ServiceWorkerBaseUrl)$(ProjectIndexPage)'%3B; const networkFetchEvent = '$(ServiceWorkerNetworkFetchEvent)'%3B; const swInstallEvent = '$(ServiceWorkerInstallEvent)'%3B; @@ -61,7 +61,7 @@ - const baseURL = '$(ServiceWorkerBaseURL)'%3B; + const baseURL = '$(ServiceWorkerBaseUrl)'%3B; const indexURL = '$(ServiceWorkerBaseUrl)$(ProjectHomePage)'%3B; const networkFetchEvent = '$(ServiceWorkerNetworkFetchEvent)'%3B; const swInstallEvent = '$(ServiceWorkerInstallEvent)'%3B; @@ -105,7 +105,7 @@ + Lines="const requiredFiles = [;@(DistFiles -> '"/%(ServiceWorkerBaseUrl)%(RecursiveDir)%(FileName)%(Extension)"'->Replace('\','/'),',%0D%0A');]%3B;" /> From 4033b2204649d4df68fcbe2774c2e0750942b749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Kuklau?= Date: Thu, 21 Nov 2019 06:44:11 +0100 Subject: [PATCH 4/7] the sigil was wrong so requiredFiles never actually contained the baseUrl --- .../build/BlazorPWA.MSBuild.ServiceWorker.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index b8f4bce..0c6d539 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -105,7 +105,7 @@ + Lines="const requiredFiles = [;@(DistFiles -> '"/$(ServiceWorkerBaseUrl)%(RecursiveDir)%(FileName)%(Extension)"'->Replace('\','/'),',%0D%0A');]%3B;" /> Date: Thu, 21 Nov 2019 07:03:06 +0100 Subject: [PATCH 5/7] Remove the slash, as suggested --- .../build/BlazorPWA.MSBuild.ServiceWorker.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index 0c6d539..d3eba5a 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -105,7 +105,7 @@ + Lines="const requiredFiles = [;@(DistFiles -> '"$(ServiceWorkerBaseUrl)%(RecursiveDir)%(FileName)%(Extension)"'->Replace('\','/'),',%0D%0A');]%3B;" /> Date: Thu, 5 Dec 2019 23:40:21 +0000 Subject: [PATCH 6/7] Fix leading / trailing / --- .../build/BlazorPWA.MSBuild.Manifest.targets | 2 ++ .../build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets | 2 +- Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets index 06b4b0b..fa8c7d6 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets @@ -13,6 +13,8 @@ / + /$(ManifestBaseUrl) + $(ManifestBaseUrl)/ standalone diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets index 4e4853d..092b432 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorkerRegister.targets @@ -34,7 +34,7 @@ PWAInstallable - const serviceWorkerFileName = '$(ServiceWorkerBaseURL)$(ServiceWorkerFileName)'%3B; + const serviceWorkerFileName = '$(ServiceWorkerBaseUrl)$(ServiceWorkerFileName)'%3B; const swInstalledEvent = '$(ServiceWorkerInstalledEvent)'%3B; const staticCachePrefix = '$(ServiceWorkerCacheName)-v'%3B; const updateAlertMessage = '$(ServiceWorkerUpdateAlertText)'%3B; diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets index e63a252..c039350 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets @@ -28,6 +28,8 @@ / + /$(ServiceWorkerBaseUrl) + $(ServiceWorkerBaseUrl)/ index.html From c092c2b478978e3037ec5c01044ba9de323e9580 Mon Sep 17 00:00:00 2001 From: Mister Magoo Date: Fri, 6 Dec 2019 01:01:56 +0000 Subject: [PATCH 7/7] Penultimate updates for version 1.0.2 --- .../Directory.Build.props | 2 +- .../build/BlazorPWA.MSBuild.Manifest.targets | 4 +- .../build/BlazorPWA.MSBuild.targets | 4 +- CHANGELOG.md | 10 +++++ README.md | 40 +++++++++++++++++-- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/Blazor.PWA.MSBuild.Tasks/Directory.Build.props b/Blazor.PWA.MSBuild.Tasks/Directory.Build.props index 00e8685..26650cb 100644 --- a/Blazor.PWA.MSBuild.Tasks/Directory.Build.props +++ b/Blazor.PWA.MSBuild.Tasks/Directory.Build.props @@ -1,6 +1,6 @@  - 1.0.1 + 1.0.2 beta$([System.DateTime]::Now.ToString("yyyyMMdd-HHmmss")) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets index fa8c7d6..26749ef 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets @@ -13,8 +13,8 @@ / - /$(ManifestBaseUrl) - $(ManifestBaseUrl)/ + /$(ManifestBaseUrl) + $(ManifestBaseUrl)/ standalone diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets index c039350..2c346d3 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets @@ -28,8 +28,8 @@ / - /$(ServiceWorkerBaseUrl) - $(ServiceWorkerBaseUrl)/ + /$(ServiceWorkerBaseUrl) + $(ServiceWorkerBaseUrl)/ index.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 7073990..6548fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +#### 06/12/2019 + +- PR #5 from @chucker merged with these changes +- Bug: **Property** **`ManifestBaseUrl`** - used to specify the base Url in the manifest.json was not being used in the index `` link for **manifest.json** +- Bug: **Property** **`ServiceWorkerBaseUrl`** - used to specify the base Url in the ServiceWorker was not being used in the _required files_ list. +- Bug: **Property** **`ServiceWorkerBaseUrl`** - used to specify the base Url in the ServiceWorker was not being used in the index `` link for **ServiceWorker.js** +- Also @SQL-MisterMagoo +- Added code to automatically add leading and trailing slashes to **Property** **`ManifestBaseUrl`** +- Added code to automatically add leading and trailing slashes to **Property** **`ServiceWorkerBaseUrl`** + #### 11/11/2019 - Added new **Property** **`ServiceWorkerIgnoreHosts`** - used to prevent service worker installation on specific hosts e.g. localhost diff --git a/README.md b/README.md index 913f00d..20b02b8 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ I don't have a Mac, but I believe Safari does not prompt on desktop either. Install the nuget BlazorPWA.MsBuild #### Package Manager: -`Install-Package BlazorPWA.MSBuild -Version 1.0.1` +`Install-Package BlazorPWA.MSBuild -Version 1.0.2` #### .NET Cli: -`dotnet add package BlazorPWA.MSBuild --version 1.0.1` +`dotnet add package BlazorPWA.MSBuild --version 1.0.2` #### Package Reference -`` +`` ## Configuration @@ -171,6 +171,40 @@ The service worker will not register itself when the `hostname` matches anything *Note: the single quotes around each hostname are required for now* +### Handle different base Urls for different configurations + +Sample csproj file for two different base Urls + +``` XML + + + + netcoreapp3.1 + true + true + + + + prod + prod + + + + dev + dev + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + +``` +This project file use **`ManifestForce`** and **`ServiceWorkerForce`** to ensure that the **manifest.json** and **ServiceWorker.js** files are rebuilt - otherwise they would not change when you changed configuration. + ## Roadmap - [ ] At the moment, there is only one choice for caching strategy - Cache First/Network Fallback - I will add more (https://developers.google.com/web/ilt/pwa/introduction-to-progressive-web-app-architectures#caching_strategies_supported_by_sw-toolbox)