mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 10:49:19 +02:00
Add an launch inspector command to Aspire Dashboard (#1283)
* Upgrade to Aspire 9.2.0 Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * Remove workload installs from CI pipeline Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * Missed package upgrade Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * Fix usings Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * Add Open Inspector command Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * Fix broken test Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * PR comments Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> * More PR comments Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com> --------- Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
This commit is contained in:
43
src/WireMock.Net.Aspire/WireMockInspector.cs
Normal file
43
src/WireMock.Net.Aspire/WireMockInspector.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Aspire.Hosting.WireMock;
|
||||
|
||||
internal static class WireMockInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Opens the WireMockInspector tool to inspect the WireMock server.
|
||||
/// </summary>
|
||||
/// <param name="wireMockUrl"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
/// <remarks>
|
||||
/// Copy of <see href="https://github.com/WireMock-Net/WireMockInspector/blob/main/src/WireMock.Net.Extensions.WireMockInspector/WireMockServerExtensions.cs" />
|
||||
/// without requestFilters and no call to WaitForExit() method in the process so it doesn't block the caller.
|
||||
/// </remarks>
|
||||
public static void Inspect(string wireMockUrl, [CallerMemberName] string title = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
var arguments = $"attach --adminUrl {wireMockUrl} --autoLoad --instanceName \"{title}\"";
|
||||
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "wiremockinspector",
|
||||
Arguments = arguments,
|
||||
UseShellExecute = false
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException
|
||||
(
|
||||
message: @"Cannot find installation of WireMockInspector.
|
||||
Execute the following command to install WireMockInspector dotnet tool:
|
||||
> dotnet tool install WireMockInspector --global --no-cache --ignore-failed-sources
|
||||
To get more info please visit https://github.com/WireMock-Net/WireMockInspector",
|
||||
innerException: e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user