Please describe which feature you have a question about?
I'm implementing the backend build for a dotnet 3.1 application. I had a rocky start (#676), but finally got dotnet 3.1 properly installed. I'm now running into a new issue that prevents the amplifyPush --simple command from properly running. I'm getting the following error:
Error: Package command failed with error [Error: Command failed with exit code 1: dotnet lambda package --framework netcoreapp3.1 --configuration Release --output-package /codebuild/output/src180379897/src/react-amplify/amplify/backend/function/ReactAmplify/dist/latest-build.zip
After further investigation, I am confident in saying that it's caused because the session isn't restarted, due to this output from the dotnet install:
Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.
2020-05-18T18:57:59.665Z [INFO]: You can invoke the tool using the following command: dotnet-lambda
Tool 'amazon.lambda.tools' (version '4.0.0') was successfully installed.
I guess I see a possible solution being 1 of 3 things:
amplifyPush --simple need to be adjusted for dotnet builds?Provide additional details
amplify.yml
version: 0.1
backend:
phases:
preBuild:
commands:
- rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
- yum install -y dotnet-host-3.1.4
- yum install -y dotnet-sdk-3.1
- dotnet tool install -g Amazon.Lambda.Tools
- dotnet tool install -g Amazon.Lambda.TestTool-3.1
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Can this issue get some attention please?
It's been three weeks and I still don't have a solution. Can anyone look into this please?
I am having the same issue , Any solution yet?
+1
I honestly can not fathom why the amplify team would not have .net core support on their build images by default. It feels like a major oversight to me.
@CoreyPritchard FWIW, the workaround my awesome team member, @alexkates , came up with was to create our own custom build image. See details here, https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html
In an attempt to save someone several hours... here is the step-by-step procedure to get this to work.
git clone https://github.com/aws-amplify/amplify-console.gitcd images/latest && docker build -t amplify-console/buildimage:latest .FROM amplify-console/buildimage:latest
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum -y update && \
yum -y install \
dotnet-host-3.1.4 \
dotnet-sdk-3.1
RUN dotnet tool install -g Amazon.Lambda.Tools
RUN dotnet tool install -g Amazon.Lambda.TestTool-3.1
RUN echo "export PATH=\$PATH:/root/.dotnet/tools" >> /root/.bashrc
ENTRYPOINT [ "bash", "-c"]
@swaminator is it any ETA on when this will be fixed?
If any other needs it, so have I made a github repo based on the solution from @alexkates. That can be used to build the docker image in an AWS Codebuild project. Then you do not have to struggle to set up Docker on your machine if you do not have it already and you are following DevOps principals :)
Installing .NET on every build worked for me. The install is super quick if you believe the build timestamps. Less than 10 sec.
Here is the amplify.yaml file I used:
version: 1
backend:
phases:
preBuild:
commands:
- curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh
- chmod +x *.sh
- ./dotnet-install.sh
- export PATH=$PATH:/root/.dotnet:/root/.dotnet/tools
- export DOTNET_ROOT="/root/.dotnet"
- dotnet --version
- dotnet tool install -g Amazon.Lambda.Tools
- dotnet tool install -g Amazon.Lambda.TestTool-3.1
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
# No changes from default amplify.yml
Build Log
# Starting phase: preBuild
2020-11-27T23:46:35.332Z [INFO]: # Executing command: curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh
2020-11-27T23:46:35.703Z [INFO]: # Executing command: chmod +x *.sh
2020-11-27T23:46:35.704Z [INFO]: # Executing command: ./dotnet-install.sh
2020-11-27T23:46:35.710Z [INFO]: dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
2020-11-27T23:46:35.711Z [INFO]: dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.
2020-11-27T23:46:36.513Z [INFO]: dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.404/dotnet-sdk-3.1.404-linux-x64.tar.gz
2020-11-27T23:46:37.853Z [INFO]: dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.404/dotnet-sdk-3.1.404-linux-x64.tar.gz
2020-11-27T23:46:40.827Z [INFO]: dotnet-install: Adding to current process PATH: `/root/.dotnet`. Note: This change will be visible only when sourcing script.
2020-11-27T23:46:40.829Z [INFO]: dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.
# Executing command: export PATH=/usr/local/rvm/gems/ruby-2.4.6/bin:/usr/local/rvm/gems/ruby-2.4.6@global/bin:/usr/local/rvm/rubies/ruby-2.4.6/bin:/usr/local/rvm/bin:/root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:/root/.nvm/versions/node/v10.16.0/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet:/root/.dotnet/tools
# Executing command: export DOTNET_ROOT=/root/.dotnet
2020-11-27T23:46:40.983Z [INFO]: # Executing command: dotnet --version
2020-11-27T23:46:41.496Z [INFO]: 3.1.404
Is it just me or have new build images with .NET 3.1 installed been deployed? My above amplify.yaml now fails because all of the .NET install commands in the preBuild section are no longer needed.
yes, it has to have been fixed since the default image now works.
@kjones yes we rolled out a new default image this week. If you have any questions please reopen this issue.