By default Heroku does not support the .NET platform. But as they say, you can use any language that runs on Linux with Heroku via a third-party buildpack. And that’s exactly what happens with .NET, so we can use the dotnetcore-buildpack.

  1. From Heroku main page, create a new application (i.e. mydotnetapp with region set to Europe).

  2. Log in to Heroku from command line:

     $ heroku login
    
  3. Set the buildpack our new app has to use:

     $ heroku buildpacks:set jincod/dotnetcore -a mydotnetapp
    
  4. Set up Git in our project directory, keeping in mind the buildpack expects to find a Program.cs file in this directory.

     $ git init
     $ heroku git:remote -a mydotnetapp
    
  5. It’s probably a good idea to create a .gitignore file to exclude everything we don’t need to send to Heroku:

     .DS_Store
     bin/
     obj/
     appsettings.Development.json
    
  6. Push project to Heroku:

     $ git add .
     $ git commit -m "First working version"
     $ git push heroku master
    

It’s important to realize that this process is a bit different from what we do when deploying to other platforms as Azure:

  • Azure ⇒ we push some publish folder after running:

      dotnet publish -c Release -o ./publish
    
  • Heroku ⇒ we push the folder with our .NET project, the one that includes the Program.cs file (we don’t need to previously run any dotnet command ourselves).