Skip to content

Commit fc50efc

Browse files
Adds publishing Abstractions to NuGet. Closes #1248
1 parent d0bff06 commit fc50efc

5 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,33 @@ jobs:
193193
if: contains(matrix.architecture, 'win-')
194194
run: |
195195
$(Get-FileHash ./${{ env.release }}/dev-proxy-installer-${{ matrix.architecture }}-${{ github.ref_name }}.exe -Algorithm SHA256).Hash
196+
publish_nuget:
197+
name: Publish to NuGet
198+
needs: [publish_binaries]
199+
runs-on: ubuntu-latest
200+
environment:
201+
name: gh_releases
202+
steps:
203+
- name: Checkout code
204+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
205+
- name: Setup .NET
206+
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
207+
with:
208+
dotnet-version: 10.0.x
209+
- name: Get version from tag
210+
id: get_version
211+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
212+
- name: Pack
213+
run: >
214+
dotnet pack ./DevProxy.Abstractions/DevProxy.Abstractions.csproj
215+
-c Release
216+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }}
217+
-o ./nupkg
218+
- name: Push to NuGet
219+
run: >
220+
dotnet nuget push ./nupkg/DevProxy.Abstractions.${{ steps.get_version.outputs.VERSION }}.nupkg
221+
--api-key ${{ secrets.NUGET_API_KEY }}
222+
--source https://api.nuget.org/v3/index.json
196223
create_release:
197224
name: Create Release
198225
needs: [publish_binaries]

DevProxy.Abstractions/DevProxy.Abstractions.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,26 @@
1010
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
13+
<IsPackable>true</IsPackable>
14+
<PackageId>DevProxy.Abstractions</PackageId>
15+
<Title>Dev Proxy Abstractions</Title>
16+
<Authors>Dev Proxy</Authors>
17+
<Description>Abstractions for building custom Dev Proxy plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path.</Description>
18+
<PackageTags>devproxy;api;proxy;testing;mocking;plugins</PackageTags>
19+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
20+
<PackageProjectUrl>https://aka.ms/devproxy</PackageProjectUrl>
21+
<RepositoryUrl>https://github.com/dotnet/dev-proxy</RepositoryUrl>
22+
<RepositoryType>git</RepositoryType>
23+
<PackageReadmeFile>README.md</PackageReadmeFile>
24+
<PackageIcon>icon.png</PackageIcon>
25+
<NoWarn>NU5104</NoWarn>
1326
</PropertyGroup>
1427

28+
<ItemGroup>
29+
<None Include="README.md" Pack="true" PackagePath="\" />
30+
<None Include="..\media\icon.png" Pack="true" PackagePath="\" />
31+
</ItemGroup>
32+
1533
<ItemGroup>
1634
<PackageReference Include="Markdig" Version="0.41.3" />
1735
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.4" />

DevProxy.Abstractions/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Dev Proxy Abstractions
2+
3+
[![NuGet Version](https://img.shields.io/nuget/v/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions)
4+
[![NuGet Downloads](https://img.shields.io/nuget/dt/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions)
5+
6+
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.
7+
8+
## What This Package Does
9+
10+
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.
11+
12+
## Usage
13+
14+
Create a new class library project and add a reference to this package:
15+
16+
```bash
17+
dotnet add package DevProxy.Abstractions
18+
```
19+
20+
Then, implement the `IPlugin` interface or inherit from `BasePlugin`:
21+
22+
```csharp
23+
using DevProxy.Abstractions.Plugins;
24+
using DevProxy.Abstractions.Proxy;
25+
using Microsoft.Extensions.Configuration;
26+
using Microsoft.Extensions.DependencyInjection;
27+
28+
public class MyPlugin : BasePlugin
29+
{
30+
public override string Name => nameof(MyPlugin);
31+
32+
public MyPlugin(
33+
IPluginEvents pluginEvents,
34+
IProxyContext context,
35+
ISet<UrlToWatch> urlsToWatch,
36+
IConfigurationSection? configSection = null
37+
) : base(pluginEvents, context, urlsToWatch, configSection)
38+
{
39+
}
40+
41+
public override async Task BeforeRequestAsync(
42+
ProxyRequestArgs e,
43+
CancellationToken cancellationToken)
44+
{
45+
// Your custom logic here
46+
}
47+
}
48+
```
49+
50+
For more information, see the [Dev Proxy documentation](https://aka.ms/devproxy/docs).

DevProxy.Plugins/DevProxy.Plugins.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1212
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1313
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
14+
<IsPackable>false</IsPackable>
1415
</PropertyGroup>
1516
<PropertyGroup Condition="'$(Configuration)'=='Release'">
1617
<NoWarn>CS1998</NoWarn>

DevProxy/DevProxy.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1818
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1919
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
20+
<IsPackable>false</IsPackable>
2021
</PropertyGroup>
2122

2223
<ItemGroup>

0 commit comments

Comments
 (0)