Home > Net >  Why am I getting the error: "Error while executing command: dotnet publish"?
Why am I getting the error: "Error while executing command: dotnet publish"?

Time:10-19

I created the buildspec.yml file to use in AWS CodeBuild and am getting the error below when I run it:

COMMAND_EXECUTION_ERROR Message: Error while executing command: dotnet publish -c release -o build/outputs/Host. Reason: exit status 1

I already check the path I'm passing in the '-o' parameter, I've even removed it, but I keep getting the error.

I am using dotnet 5.0. Do I need to install it before I build it? If yes, how can I do this?

Below I put the snippet that matters from my buildspec.yml:

version: 0.2

phases:
  install:
    runtime-versions:
      docker: 18
  
  pre_build:
    commands:
      - echo pre-build started on `date`
      - echo Logging in to Amazon ECR...
      - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
      
  build:
    commands:
      - echo Building dotnet API...
      - cd aspnet-core/src/SITR.Web.Host
      - echo Executing dotnet restore...
      - dotnet restore
      - echo Executing dotnet publish...
      - dotnet publish -c release -o ../../../docker/build/outputs/Host
  
  post_build:
    commands:
      - echo Pushing the Docker image...
      - docker-compose --file=docker-compose-qa.yml push
      - echo Build completed on `date`

CodePudding user response:

dotnet: 5.0 is supported only in dotnet run-time. But you are using docker runtime. So either you have to change your runtime, or manually setup/install dotnet in your run-time.

  • Related