Heroku Push rejected, failed to compile ASP.NET Core app
what is heroku-16?
there are different types of distros(stacks
) which contains your app:
- heroku-16
- cedar-14 (supports dotNet-core.)
thats why we will switch to cedar-14
how to fix:
1- install heroku cli. (https://devcenter.heroku.com/articles/heroku-cli)
2- open cmd. type:
cd to/project/Root heroku stack:set cedar-14git push heroku master
You could create a Dockerfile to generate a Docker image runnable on Heroku.
FROM microsoft/aspnetcore-build:2.0 AS build-envWORKDIR /app# Copy csproj and restore as distinct layersCOPY *.csproj ./RUN dotnet restore# Copy everything else and buildCOPY . ./RUN dotnet publish -c Release -o out# Build runtime imageFROM microsoft/aspnetcore:2.0WORKDIR /appCOPY --from=build-env /app/out .CMD ASPNETCORE_URLS=http://*:$PORT dotnet <YOUR_API_NAME>.dll
Then you can publish it to Heroku either directly using these Docker commands:
docker build -t aspnetapp <YOUR_API_NAME>docker login --username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.comdocker tag aspnetapp registry.heroku.com/$HEROKU_APP_NAME/webdocker push registry.heroku.com/$HEROKU_APP_NAME/web
In order these commands:
- Create a Docker image and builds a release of your project in it
- Connect to Heroku's docker registry using your credentials
- Creates a new tag for your image
- Publishes your image to your Heroku app
However, if your machine does not support Docker, you can also use CircleCI to run these commands. More details here: https://www.codingnagger.com/2018/02/21/continuous-delivery/