Docs menu

.NET on Primcloud

How Primcloud detects a .NET app, chooses what to build, publishes it, and works out its process types.

On this page

Detection#

Primcloud builds your app as .NET when the root of your repo has any of:

  • A solution file: .sln or .slnx
  • A project file: .csproj, .vbproj, or .fsproj
  • A single C# file: .cs

What gets built. The build picks the first of:

  1. The solution file named by a SOLUTION_FILE secret.
  2. Solution file named in project.toml under [com.heroku.buildpacks.dotnet].
  3. The single solution file at the root, if there's exactly one.
  4. The single project file at the root, if there's exactly one and no solution file is present.
  5. The single C# file-based app at the root, if there's exactly one and no solution or project files are present.

Anything ambiguous fails the build: several solution files with none named, several project files with no solution, or several .cs files with neither.

The build#

The build runs dotnet publish on that target for Linux, which restores your NuGet packages (<PackageReference> entries, or packages.config in older projects) and compiles your app into bin/publish. Local tools in .config/dotnet-tools.json are restored first and are on the PATH during the build.

To choose the solution, configuration, or log verbosity, see Customizing the build.

File-based apps. A .cs file at the root with no project or solution is built as a file-based app, with Microsoft.NET.Sdk and net10.0 by default. Change them with directives in the file:

Program.cs
#:sdk Microsoft.NET.Sdk.Web
#:property TargetFramework=net11.0
#:property PublishAot=false

Reused between builds#

Your NuGet packages, the .NET SDK, and the .NET runtime are reused from the previous build when they haven't changed. The build log shows Reusing package cache when packages are reused; the package cache is cleared after 20 builds in a row reuse it.

Process types#

A Procfile decides your processes; see Formations.

Without one, every project using one of these SDKs becomes a process type:

  • Microsoft.NET.Sdk with OutputType=Exe
  • Microsoft.NET.Sdk.Worker
  • Microsoft.NET.Sdk.Web
  • Microsoft.NET.Sdk.Razor

Each is named after its AssemblyName, lowercased, with spaces, dots, and underscores turned into hyphens and other symbols removed. If exactly one of them is a web app, it runs as web instead.

Port. Projects using Microsoft.NET.Sdk.Web or Microsoft.NET.Sdk.Razor are started with --urls http://*:$PORT, so an ASP.NET Core app listens on the right port with no code of its own. Any other project that serves HTTP has to read $PORT itself, or set ASPNETCORE_URLS to http://0.0.0.0:$PORT.

Environment. Every process gets these, plus your secrets:

Variable Value Purpose
DOTNET_ROOT Path to the installed .NET runtime So dotnet can find its shared framework.
DOTNET_CLI_TELEMETRY_OPTOUT true Opts out of .NET CLI telemetry.
DOTNET_NOLOGO true Mutes the .NET welcome banner.
DOTNET_RUNNING_IN_CONTAINER true ASP.NET Core uses this to skip host-specific setup.
PORT 5000 The port your web process listens on. Set on web only.
PATH With .NET root prepended So dotnet and installed tools are on PATH.