# ProcessCommandResultContext

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/ApplicationModel/ProcessCommandResultContext.cs)

Context passed to callback to configure [ExecuteCommandResult](/reference/api/csharp/aspire.hosting/executecommandresult.md) when using [ResourceBuilderExtensions.WithProcessCommand(IResourceBuilder<TResource>, string, string, string, IReadOnlyList<string>, ProcessCommandOptions?)](/reference/api/csharp/aspire.hosting/resourcebuilderextensions/methods.md#withprocesscommand-iresourcebuilder-tresource-string-string-string-ireadonlylist-string-processcommandoptions).

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class ProcessCommandResultContext
{
    // ...
}
```

## Constructors

- [ProcessCommandResultContext](/reference/api/csharp/aspire.hosting/processcommandresultcontext/constructors.md#constructor)

## Properties

- [CancellationToken](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#cancellationtoken) : `CancellationToken` `get; init` -- Gets the cancellation token.
- [ExitCode](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#exitcode) : `int` `get; init` -- Gets the process exit code.
- [Logger](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#logger) : `ILogger` `get; init` -- Gets the logger for the command invocation.
- [Output](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#output) : `IReadOnlyList<string>` `get; init` -- Gets the retained stdout and stderr output lines in the order observed by the process runner.
- [ProcessCommandSpec](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#processcommandspec) : [ProcessCommandSpec](/reference/api/csharp/aspire.hosting/processcommandspec.md) `get; init` -- Gets the process command specification used for the command invocation.
- [ResourceName](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#resourcename) : `string` `get; init` -- Gets the name of the resource the command was configured on.
- [ServiceProvider](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#serviceprovider) : `IServiceProvider` `get; init` -- Gets the service provider.
- [TotalOutputLineCount](/reference/api/csharp/aspire.hosting/processcommandresultcontext/properties.md#totaloutputlinecount) : `int` `get; init` -- Gets the total number of stdout and stderr lines observed by the process runner.

## Methods

- [GetFormattedOutput(int, string)](/reference/api/csharp/aspire.hosting/processcommandresultcontext/methods.md#getformattedoutput-int-string) : `string` -- Returns the last `maxLines` process output lines formatted for display.
