# DotnetToolResourceExtensions Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [DotnetToolResourceExtensions](/reference/api/csharp/aspire.hosting/dotnettoolresourceextensions.md)
- Kind: `Methods`
- Members: `8`

Provides extension methods for adding Dotnet Tool resources to the application model.

## AddDotnetTool(IDistributedApplicationBuilder, string, string)

- Name: `AddDotnetTool(IDistributedApplicationBuilder, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<DotnetToolResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L29)

Adds a .NET tool resource to the application model.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<DotnetToolResource> AddDotnetTool(
        this IDistributedApplicationBuilder builder,
        string name,
        string packageId)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md))
  The [IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md).
- `name` (`string`)
  The name of the resource.
- `packageId` (`string`)
  The package id of the tool.

## Returns

`IResourceBuilder<DotnetToolResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddDotnetTool(IDistributedApplicationBuilder, T)

- Name: `AddDotnetTool(IDistributedApplicationBuilder, T)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L44-L54)

Adds a .NET tool resource to the distributed application model and configures it for execution via the `dotnet tool exec` command.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> AddDotnetTool<T>(
        this IDistributedApplicationBuilder builder,
        T resource)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md))
  The distributed application builder to which the .NET tool resource will be added.
- `resource` (`T`)
  The .NET tool resource instance to add and configure.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method is not available in polyglot app hosts. Use the overload with name and packageId instead.

## ATS metadata

### Ignored by ATS

- Reason: Open generic IResource constraint -- not ATS-compatible.

## WithToolIgnoreExistingFeeds(IResourceBuilder<T>)

- Name: `WithToolIgnoreExistingFeeds(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L187-L188)

Configures the tool to use only the specified package sources, ignoring existing NuGet configuration.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolIgnoreExistingFeeds<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithToolIgnoreFailedSources(IResourceBuilder<T>)

- Name: `WithToolIgnoreFailedSources(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L201-L202)

Configures the resource to treat package source failures as warnings.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolIgnoreFailedSources<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithToolPackage(IResourceBuilder<T>, string)

- Name: `WithToolPackage(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L129-L130)

Sets the package identifier for the tool configuration associated with the resource builder.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolPackage<T>(
        this IResourceBuilder<T> builder,
        string packageId)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.
- `packageId` (`string`)
  The package identifier to assign to the tool configuration. Cannot be null.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithToolPrerelease(IResourceBuilder<T>)

- Name: `WithToolPrerelease(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L158-L159)

Allows prerelease versions of the tool to be used

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolPrerelease<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithToolSource(IResourceBuilder<T>, string)

- Name: `WithToolSource(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L173-L174)

Adds a NuGet package source for tool acquisition.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolSource<T>(
        this IResourceBuilder<T> builder,
        string source)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.
- `source` (`string`)
  The source to add.

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithToolVersion(IResourceBuilder<T>, string)

- Name: `WithToolVersion(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DotnetToolResourceExtensions.cs#L144-L145)

Sets the package version for a tool to use.

```csharp
public static class DotnetToolResourceExtensions
{
    public static IResourceBuilder<T> WithToolVersion<T>(
        this IResourceBuilder<T> builder,
        string version)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  The `ApplicationModel.IResourceBuilder`1`.
- `version` (`string`)
  The package version to use

## Returns

[IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- The `ApplicationModel.IResourceBuilder`1` for chaining.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
