# DotnetProjectResource

- Module: [Aspire.Hosting.Dotnet](/reference/api/go/aspire.hosting.dotnet.md)
- Version: `17.0.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

A resource that represents an SDK-style .NET project or file-based C# app added by path.

## Remarks

A `DotnetProjectResource` is added by path and is
launched as an executable: `dotnet run --project <path>` for a project file, or
`dotnet run --file <path>` for a file-based app (a `.cs` file).
Supported project files are `.csproj`, `.fsproj`, and `.vbproj`.
F# scripts and non-SDK project systems are not supported.
Resources created by `AddDotnetProject` support the same .NET SDK container-publishing pipeline as
resources created by `AddProject`. A directly constructed resource must be given project metadata and
explicitly configured for publishing by its builder.

## Definition

```go
type DotnetProjectResource interface {
    DotnetProgramResource
    IComputeResource
    IContainerFilesDestinationResource
    Resource
    ResourceWithArgs
    ResourceWithEndpoints
    ResourceWithEnvironment
    ResourceWithWaitSupport
}
```

## Embeds

- `DotnetProgramResource`
- `IComputeResource`
- `IContainerFilesDestinationResource`
- `Resource`
- `ResourceWithArgs`
- `ResourceWithEndpoints`
- `ResourceWithEnvironment`
- `ResourceWithWaitSupport`

## Methods

- [DisableForwardedHeaders](/reference/api/go/aspire.hosting.dotnet/dotnetprojectresource/disableforwardedheaders.md) -- `method` -- Disables automatic forwarded-header configuration when publishing the .NET project.
  ```go
  DisableForwardedHeaders() DotnetProjectResource
  ```
- [WithBuildEnvironment](/reference/api/go/aspire.hosting.dotnet/dotnetprojectresource/withbuildenvironment.md) -- `method` -- Adds an environment variable to the build process for a .NET project.
  ```go
  WithBuildEnvironment(name string, value string) DotnetProjectResource
  ```
- [WithEndpointsInEnvironment](/reference/api/go/aspire.hosting.dotnet/dotnetprojectresource/withendpointsinenvironment.md) -- `method` -- Configures endpoint environment-variable injection for a .NET project in polyglot AppHosts.
  ```go
  WithEndpointsInEnvironment(endpointNames []string) DotnetProjectResource
  ```
- [WithReplicas](/reference/api/go/aspire.hosting.dotnet/dotnetprojectresource/withreplicas.md) -- `method` -- Configures the number of replicas of the .NET project.
  ```go
  WithReplicas(replicas float64) DotnetProjectResource
  ```
