# DotnetProjectHostingExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Dotnet](/reference/api/csharp/aspire.hosting.dotnet.md)
- Version: `17.0.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting.Dotnet/DotnetProjectHostingExtensions.cs)

Provides extension methods for adding SDK-style .NET projects and file-based C# apps (by path) to an `Hosting.IDistributedApplicationBuilder`.

## Definition

```csharp
namespace Aspire.Hosting;

public static class DotnetProjectHostingExtensions
{
    // ...
}
```

## Methods

- [AddDotnetProject(IDistributedApplicationBuilder, string, string)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#adddotnetproject-idistributedapplicationbuilder-string-string) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats ignored` -- Adds an SDK-style .NET project or file-based C# app to the application model.
- [AddDotnetProject(IDistributedApplicationBuilder, string, string, Action<ProjectResourceOptions>)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#adddotnetproject-idistributedapplicationbuilder-string-string-action-projectresourceoptions) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats ignored` -- Adds an SDK-style .NET project or file-based C# app to the application model.
- [DisableForwardedHeaders(IResourceBuilder<DotnetProjectResource>)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#disableforwardedheaders-iresourcebuilder-dotnetprojectresource) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats export` -- Disables automatic forwarded-header configuration when publishing the .NET project.
- [GetProjectMetadata(DotnetProjectResource)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#getprojectmetadata-dotnetprojectresource) : `IProjectMetadata` `extension` `ats ignored` -- Gets the project metadata for the .NET project resource.
- [WithBuildEnvironment(IResourceBuilder<DotnetProjectResource>, string, string)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#withbuildenvironment-iresourcebuilder-dotnetprojectresource-string-string) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats export` -- Adds an environment variable to the build process for a .NET project.
- [WithBuildEnvironment(IResourceBuilder<DotnetProjectResource>, Action<EnvironmentCallbackContext>)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#withbuildenvironment-iresourcebuilder-dotnetprojectresource-action-environmentcallbackcontext) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats ignored` -- Adds a callback that configures build-only environment variables for a .NET project.
- [WithBuildEnvironment(IResourceBuilder<DotnetProjectResource>, Func<EnvironmentCallbackContext, Task>)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#withbuildenvironment-iresourcebuilder-dotnetprojectresource-func-environmentcallbackcontext-task) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats ignored` -- Adds an asynchronous callback that configures build-only environment variables for a .NET project.
- [WithEndpointsInEnvironment(IResourceBuilder<DotnetProjectResource>, Func<EndpointAnnotation, bool>)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#withendpointsinenvironment-iresourcebuilder-dotnetprojectresource-func-endpointannotation-bool) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats ignored` -- Configures which endpoints contribute environment variables for the .NET project.
- [WithReplicas(IResourceBuilder<DotnetProjectResource>, int)](/reference/api/csharp/aspire.hosting.dotnet/dotnetprojecthostingextensions/methods.md#withreplicas-iresourcebuilder-dotnetprojectresource-int) : `IResourceBuilder<DotnetProjectResource>` `extension` `ats export` -- Configures the number of replicas of the .NET project.
