On this page

.NET

Guara Cloud fully supports .NET applications, including ASP.NET Core web APIs, MVC apps, Blazor, and .NET console applications.

Supported versions

The following .NET versions are auto-detected:

  • .NET 8.0 (LTS)
  • .NET 9.0 (Current)

The version is auto-detected from the TargetFramework element in your .csproj file or from global.json.

<!-- MyApp.csproj -->
<PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

Deploy with Dockerfile

A multi-stage build is the recommended approach for .NET applications. It builds your project with the full SDK, then runs it using the lightweight ASP.NET runtime.

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

COPY *.csproj .
RUN dotnet restore

COPY . .
RUN dotnet publish -c Release -o /out

FROM mcr.microsoft.com/dotnet/aspnet:8.0

WORKDIR /app
COPY --from=build /out .

EXPOSE 3000

ENV ASPNETCORE_URLS=http://+:3000

CMD ["dotnet", "MyApp.dll"]

Deploy with Buildpack

If your repository does not contain a Dockerfile, Guara Cloud automatically detects your .NET project by the presence of a .csproj file.

The auto-detection will:

  1. Detect the .NET version from TargetFramework in .csproj or from global.json
  2. Run dotnet restore and dotnet publish automatically
  3. Auto-detect ASP.NET Core applications
  4. Start the application

Port configuration

Your application must listen on the port configured in your service settings. The default is 3000, but you can change it at any time to match your application.

The recommended way to configure this in ASP.NET Core is through the ASPNETCORE_URLS environment variable:

ASPNETCORE_URLS=http://+:${PORT:-3000}

Or programmatically in Program.cs:

var port = Environment.GetEnvironmentVariable("PORT") ?? "3000";
app.Run($"http://+:{port}");

Example project structure

my-dotnet-app/
  MyApp.csproj
  MyApp.sln
  Program.cs
  Controllers/
  Models/
  appsettings.json
  appsettings.Production.json
  Dockerfile          # optional — omit to use Buildpack

Environment variables

These environment variables are commonly used with .NET deployments:

VariableRecommended valueDescription
ASPNETCORE_URLShttp://+:${PORT:-3000}URL and port the app listens on
ASPNETCORE_ENVIRONMENTProductionSets the hosting environment
DOTNET_RUNNING_IN_CONTAINERtrueOptimizes .NET for container environments
PORTSet by platformThe port your application must listen on

Common pitfalls