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/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..5c95081 100644 --- a/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj +++ b/Darnton.Blazor.DeviceInterop/Darnton.Blazor.DeviceInterop.csproj @@ -4,25 +4,31 @@ 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"); } ///