From fc50efc4c4ee42c1b92035d53c02aee83b200b93 Mon Sep 17 00:00:00 2001 From: waldekmastykarz Date: Sat, 11 Apr 2026 18:32:39 +0200 Subject: [PATCH 1/2] Adds publishing Abstractions to NuGet. Closes #1248 --- .github/workflows/create-release.yml | 27 ++++++++++ .../DevProxy.Abstractions.csproj | 18 +++++++ DevProxy.Abstractions/README.md | 50 +++++++++++++++++++ DevProxy.Plugins/DevProxy.Plugins.csproj | 1 + DevProxy/DevProxy.csproj | 1 + 5 files changed, 97 insertions(+) create mode 100644 DevProxy.Abstractions/README.md diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index d4864b41..e13dbd4f 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -193,6 +193,33 @@ jobs: if: contains(matrix.architecture, 'win-') run: | $(Get-FileHash ./${{ env.release }}/dev-proxy-installer-${{ matrix.architecture }}-${{ github.ref_name }}.exe -Algorithm SHA256).Hash + publish_nuget: + name: Publish to NuGet + needs: [publish_binaries] + runs-on: ubuntu-latest + environment: + name: gh_releases + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 + with: + dotnet-version: 10.0.x + - name: Get version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + - name: Pack + run: > + dotnet pack ./DevProxy.Abstractions/DevProxy.Abstractions.csproj + -c Release + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + -o ./nupkg + - name: Push to NuGet + run: > + dotnet nuget push ./nupkg/DevProxy.Abstractions.${{ steps.get_version.outputs.VERSION }}.nupkg + --api-key ${{ secrets.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json create_release: name: Create Release needs: [publish_binaries] diff --git a/DevProxy.Abstractions/DevProxy.Abstractions.csproj b/DevProxy.Abstractions/DevProxy.Abstractions.csproj index dc9f818f..943e80a7 100644 --- a/DevProxy.Abstractions/DevProxy.Abstractions.csproj +++ b/DevProxy.Abstractions/DevProxy.Abstractions.csproj @@ -10,8 +10,26 @@ true true AllEnabledByDefault + true + DevProxy.Abstractions + Dev Proxy Abstractions + Dev Proxy + Abstractions for building custom Dev Proxy plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path. + devproxy;api;proxy;testing;mocking;plugins + MIT + https://aka.ms/devproxy + https://github.com/dotnet/dev-proxy + git + README.md + icon.png + NU5104 + + + + + diff --git a/DevProxy.Abstractions/README.md b/DevProxy.Abstractions/README.md new file mode 100644 index 00000000..400ff73e --- /dev/null +++ b/DevProxy.Abstractions/README.md @@ -0,0 +1,50 @@ +# Dev Proxy Abstractions + +[![NuGet Version](https://img.shields.io/nuget/v/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions) +[![NuGet Downloads](https://img.shields.io/nuget/dt/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions) + +Abstractions for building custom [Dev Proxy](https://aka.ms/devproxy) plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path. + +## What This Package Does + +This package provides the interfaces, base classes, and models needed to build custom Dev Proxy plugins. Use it when you want to extend Dev Proxy with your own functionality. + +## Usage + +Create a new class library project and add a reference to this package: + +```bash +dotnet add package DevProxy.Abstractions +``` + +Then, implement the `IPlugin` interface or inherit from `BasePlugin`: + +```csharp +using DevProxy.Abstractions.Plugins; +using DevProxy.Abstractions.Proxy; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +public class MyPlugin : BasePlugin +{ + public override string Name => nameof(MyPlugin); + + public MyPlugin( + IPluginEvents pluginEvents, + IProxyContext context, + ISet urlsToWatch, + IConfigurationSection? configSection = null + ) : base(pluginEvents, context, urlsToWatch, configSection) + { + } + + public override async Task BeforeRequestAsync( + ProxyRequestArgs e, + CancellationToken cancellationToken) + { + // Your custom logic here + } +} +``` + +For more information, see the [Dev Proxy documentation](https://aka.ms/devproxy/docs). diff --git a/DevProxy.Plugins/DevProxy.Plugins.csproj b/DevProxy.Plugins/DevProxy.Plugins.csproj index fe23cfe0..c4b8ec3d 100644 --- a/DevProxy.Plugins/DevProxy.Plugins.csproj +++ b/DevProxy.Plugins/DevProxy.Plugins.csproj @@ -11,6 +11,7 @@ true true AllEnabledByDefault + false CS1998 diff --git a/DevProxy/DevProxy.csproj b/DevProxy/DevProxy.csproj index bc3f80ca..00c4dacc 100644 --- a/DevProxy/DevProxy.csproj +++ b/DevProxy/DevProxy.csproj @@ -17,6 +17,7 @@ true true AllEnabledByDefault + false From 779c1ae9e58de08bd2c7a645ca745e7ed21d8738 Mon Sep 17 00:00:00 2001 From: waldekmastykarz Date: Sun, 12 Apr 2026 09:43:11 +0200 Subject: [PATCH 2/2] Address review comments: fix README sample, add NU5104 comment, stamp Version on pack, add --skip-duplicate --- .github/workflows/create-release.yml | 2 ++ .../DevProxy.Abstractions.csproj | 1 + DevProxy.Abstractions/README.md | 16 ++++------------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e13dbd4f..78a141a0 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -214,12 +214,14 @@ jobs: dotnet pack ./DevProxy.Abstractions/DevProxy.Abstractions.csproj -c Release -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + -p:Version=${{ steps.get_version.outputs.VERSION }} -o ./nupkg - name: Push to NuGet run: > dotnet nuget push ./nupkg/DevProxy.Abstractions.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + --skip-duplicate create_release: name: Create Release needs: [publish_binaries] diff --git a/DevProxy.Abstractions/DevProxy.Abstractions.csproj b/DevProxy.Abstractions/DevProxy.Abstractions.csproj index 943e80a7..30ae57d6 100644 --- a/DevProxy.Abstractions/DevProxy.Abstractions.csproj +++ b/DevProxy.Abstractions/DevProxy.Abstractions.csproj @@ -22,6 +22,7 @@ git README.md icon.png + NU5104 diff --git a/DevProxy.Abstractions/README.md b/DevProxy.Abstractions/README.md index 400ff73e..6e41bd96 100644 --- a/DevProxy.Abstractions/README.md +++ b/DevProxy.Abstractions/README.md @@ -22,22 +22,14 @@ Then, implement the `IPlugin` interface or inherit from `BasePlugin`: ```csharp using DevProxy.Abstractions.Plugins; using DevProxy.Abstractions.Proxy; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; -public class MyPlugin : BasePlugin +public class MyPlugin( + ILogger logger, + ISet urlsToWatch) : BasePlugin(logger, urlsToWatch) { public override string Name => nameof(MyPlugin); - public MyPlugin( - IPluginEvents pluginEvents, - IProxyContext context, - ISet urlsToWatch, - IConfigurationSection? configSection = null - ) : base(pluginEvents, context, urlsToWatch, configSection) - { - } - public override async Task BeforeRequestAsync( ProxyRequestArgs e, CancellationToken cancellationToken)