From ce621dd2d72cc73046c5c141e093bc2d38d715a3 Mon Sep 17 00:00:00 2001 From: Jose Luis Chavez del Cid Date: Thu, 4 May 2023 19:21:54 -0600 Subject: [PATCH 1/2] Adding configuration point (App:BasePath) in the appsettings.json file on the client side for custom location of the static resource for a blazor app, it can be "./" as default for Virtual Apps or apps on the Root, to the root folder "/" if the app is on a subfolder, or "//static.shared.com/" for shared static content. --- BlazorDeviceTestRig/wwwroot/appsettings.json | 5 +++++ .../Darnton.Blazor.DeviceInterop.csproj | 13 +++++++++---- .../Geolocation/GeolocationService.cs | 7 +++++-- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 BlazorDeviceTestRig/wwwroot/appsettings.json diff --git a/BlazorDeviceTestRig/wwwroot/appsettings.json b/BlazorDeviceTestRig/wwwroot/appsettings.json new file mode 100644 index 0000000..8e1f222 --- /dev/null +++ b/BlazorDeviceTestRig/wwwroot/appsettings.json @@ -0,0 +1,5 @@ +{ + "App": { + "BasePath": "./" + } +} \ No newline at end of file diff --git a/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj b/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj index ff0179b..b1f2d3e 100644 --- a/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj +++ b/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj @@ -4,25 +4,30 @@ net5.0 Darnton.Blazor.DeviceInterop true - 0.1.3 + 0.1.4 Bernard Darnton Blazor device interop library Blazor device interop library including wrappers for Geolocation API. Updated to .NET 5 2020 Bernard Darnton MIT https://github.com/darnton/BlazorDeviceInterop - 0.0.1.3 - 0.0.1.3 + 0.0.1.4 + 0.0.1.4 - C:\Users\user\source\repos\BlazorDeviceInterop\Darnton.Blazor.DeviceInterop\Darnton.Blazor.DeviceInterop.xml + + + + + + diff --git a/Darnton.Blazor.DeviceInterop/Geolocation/GeolocationService.cs b/Darnton.Blazor.DeviceInterop/Geolocation/GeolocationService.cs index 1240445..8e50f95 100644 --- a/Darnton.Blazor.DeviceInterop/Geolocation/GeolocationService.cs +++ b/Darnton.Blazor.DeviceInterop/Geolocation/GeolocationService.cs @@ -1,6 +1,7 @@ using Microsoft.JSInterop; using System; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; namespace Darnton.Blazor.DeviceInterop.Geolocation { @@ -14,14 +15,16 @@ public class GeolocationService : IGeolocationService /// public event EventHandler WatchPositionReceived; + private readonly IConfiguration configuration; /// /// Constructs a object. /// /// - public GeolocationService(IJSRuntime JSRuntime) + public GeolocationService(IJSRuntime JSRuntime, IConfiguration configuration) { - _jsBinder = new JSBinder(JSRuntime, "./_content/Darnton.Blazor.DeviceInterop/js/Geolocation.js"); + var basePath = configuration["App:BasePath"] ?? "./"; + _jsBinder = new JSBinder(JSRuntime, $"{basePath}/_content/Darnton.Blazor.DeviceInterop/js/Geolocation.js"); } /// From 23c57c3c83fad3d51891185616deb10999b68f38 Mon Sep 17 00:00:00 2001 From: Jose Luis Chavez del Cid Date: Mon, 29 Sep 2025 19:45:10 -0600 Subject: [PATCH 2/2] Add System.Reactive and GitHub Actions CI/CD workflow Added a NuGet package reference for `System.Reactive` (v6.0.2) to enable reactive programming capabilities in the project. Created a GitHub Actions workflow (`Darnton.Blazor.DeviceInterop.Build.yml`) to automate the build, packaging, and publishing process. The workflow includes: - Dependency restoration, project build, and NuGet package creation. - Publishing the package to GitHub Packages. - Optional steps for uploading artifacts and cleaning up generated files. This improves project automation and streamlines the distribution process. --- .../Darnton.Blazor.DeviceInterop.Build.yml | 48 +++++++++++++++++++ .../Darnton.Blazor.DeviceInterop.csproj | 1 + 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/Darnton.Blazor.DeviceInterop.Build.yml diff --git a/.github/workflows/Darnton.Blazor.DeviceInterop.Build.yml b/.github/workflows/Darnton.Blazor.DeviceInterop.Build.yml new file mode 100644 index 0000000..e006f70 --- /dev/null +++ b/.github/workflows/Darnton.Blazor.DeviceInterop.Build.yml @@ -0,0 +1,48 @@ +name: Darnton.Blazor.DeviceInterop + +env: + SUBFOLDER: './Darnton.Blazor.DeviceInterop' + PROJECT: 'Darnton.Blazor.DeviceInterop.csproj' + +on: + workflow_dispatch: + push: + paths: + - 'Darnton.Blazor.DeviceInterop/**' + branches: + - master + +jobs: + build: + runs-on: [self-hosted, webpx, build] + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore ${{ env.SUBFOLDER }}/${{ env.PROJECT }} + + - name: Build (Release) + run: dotnet build ${{ env.SUBFOLDER }}/${{ env.PROJECT }} --configuration Release --no-restore + + - name: Pack NuGet package + run: dotnet pack ${{ env.SUBFOLDER }}/${{ env.PROJECT }} --configuration Release --no-build --output ${{ github.workspace }}\nupkgs + + - name: Publish to GitHub Packages + run: dotnet nuget push ${{ github.workspace }}\nupkgs\*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload package as workflow artifact (optional) + uses: actions/upload-artifact@v4 + with: + name: Absractions + path: ./nupkgs/*.nupkg + + - name: Clean up (optional) + run: rm -Force -Recurse ./nupkgs diff --git a/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj b/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj index b1f2d3e..5c95081 100644 --- a/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj +++ b/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj @@ -28,6 +28,7 @@ +