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 434766f..26749ef 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 @@ -82,7 +84,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..d3eba5a 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;" /> PWAInstallable - const serviceWorkerFileName = '$(ServiceWorkerBaseURL)$(ServiceWorkerFileName)'%3B; + const serviceWorkerFileName = '$(ServiceWorkerBaseUrl)$(ServiceWorkerFileName)'%3B; const swInstalledEvent = '$(ServiceWorkerInstalledEvent)'%3B; const staticCachePrefix = '$(ServiceWorkerCacheName)-v'%3B; const updateAlertMessage = '$(ServiceWorkerUpdateAlertText)'%3B; @@ -110,7 +110,7 @@ diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets index e63a252..2c346d3 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 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)