# WithVolume

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a volume to a project resource.

## Definition

```go
func (ProjectResource) WithVolume(
    target string,
    name string,
    env string,
    options ...*ProjectResourceWithVolumeOptions,
) ProjectResource
```

## Parameters

- `target` (`string`) -- The mount path inside the published container.
- `name` (`string`) -- The volume name.
- `env` (`string`) -- The environment variable that receives the effective volume path.
- `options` (`...*ProjectResourceWithVolumeOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*ProjectResourceWithVolumeOptions` argument.

- `IsReadOnly` (`*bool`) -- Whether the published volume is read-only.

## Returns

[`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md) -- The same project resource builder handle for chaining.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`CSharpAppResource`](/reference/api/go/aspire.hosting/csharpappresource.md)
- [`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md)
