C#/.NET Core

Platform.sh supports deploying .NET applications by allowing developers to define a build process and pass its variables to the .NET Core build environment.

Supported versions 

Grid and Dedicated Gen 3 Dedicated Gen 2
  • 6.0
  • 3.1
None available

The following versions aren’t available in the EU-1 and US-1 regions:

  • 6.0

Consider region migration if your project is in those regions.

Specify the language 

To use .Net Core, specify dotnet as your app’s type:

type: 'dotnet:<VERSION_NUMBER>'

For example:

type: 'dotnet:6.0'

Building the application 

To build basic applications in .NET containers, it’s enough to use the dotnet publish command with the default framework-dependent deployment:

    build: |
        set -xe
        dotnet publish --output "$PLATFORM_OUTPUT_DIR" -p:UseRazorBuildServer=false -p:UseSharedCompilation=false        

where PLATFORM_OUTPUT_DIR is the output directory for compiled languages available at build time.

Typically, .NET Core builds start a collection of build servers, which are helpful for repeated builds. On Platform.sh, however, if this process isn’t disabled, the build process doesn’t finish until the idle timeout is reached.

As a result, you should include -p toggles that disable the Razor compiler for dynamic CSHTML pages (UseRazorBuildServer) and the .NET MSBuild compiler (UseSharedCompilation).

If you want multiple builds for your application, make sure to call dotnet build-server shutdown at the end of your build hook.

Running the application 

.NET Core applications should be started using the web.commands.start directive in .platform.app.yaml. This ensures that the command starts at the right moment and stops gracefully when a redeployment needs to be executed. Also, should the program terminate for any reason, it’s automatically restarted. Note that the start command must run in the foreground.

Incoming requests are passed to the application using either a TCP (default) or UNIX socket. The application must use the appropriate environment variable to determine the URI to listen on. For a TCP socket (recommended), the application must listen on, using the PORT environment variable.

There is an Nginx server sitting in front of your application. Serving static content via Nginx is recommended, as this allows you to control headers (including cache headers) and also has marginal performance benefits.

Note that HTTPS is also terminated at the Nginx proxy, so the app.UseHttpsRedirection(); line in Startup.cs should be removed. To force HTTPS-only, refer to the routes documentation.

The following example configures an environment to serve the static content folders commonly found in ASP.NET MVC templates using Nginx, while routing other traffic to the .NET application.

            root: "wwwroot"
            allow: true
            passthru: true
                # Serve these common asset types with customs cache headers.
                    allow: true
                    expires: 300s

        start: "dotnet WebApplication1.dll"

You can also route all requests to the application unconditionally:

            allow: false
            passthru: true

        start: "dotnet WebApplication1.dll"

Project templates 

The following list shows templates available for .NET Core apps. A template is a starting point for building your project. It isn’t yet ready for a production environment, but it should help you get there.



This template deploys the ASP.NET Core framework. It includes a minimalist application skeleton for demonstration, but you are free to alter it as needed. It includes demonstration-level connections for MariaDB and a Redis cache server.

ASP.NET Core is an open-source and cross-platform .NET framework for building modern cloud-based web applications.


  • .NET 2.2
  • MariaDB 10.4
  • Redis 5.0
  • Automatic TLS certificates

View the repository on GitHub.

Deploy on Platform.sh