The framework 'Microsoft.NETCore.App', version '2.1.0' was not found | Lambda Tools
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found
Scenario & Error
The Web API developed using .Net Core 2.1. As Microsoft going to end support for the said version by Aug-21. We planned to migrate it to .Net Core 3.1 and successfully migrated it. Able to run the application in the local machine using Visual Studio IDE and manually package uploading in AWS Lambda worked well. But the automation build & deployment are getting failed with below error.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
- The following frameworks were found:
3.1.15 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Fix applied
- .NET code does not contain any error. All migration code was done well.
- Root cause of the issue lies in Circle CI configuration file (yaml).
- At step “Install Serverless CLI” build pipeline run the below command,
dotnet tool install --global Amazon.Lambda.Tools --version 3.1
- The command installs the Tool 'amazon.lambda.tools' (version '3.1.0')
- However, this version of Amazon.Lambda.Tools has a strong dependency on .NETCoreApp 2.1. see below screen shot
- So, at later step, when the command “dotnet lambda package --configuration release --framework netcoreapp3.1 --output-package bin/release/netcoreapp3.1/deploy-package.zip” is run, AWS tool is unable to complete the command as it could not find the missing dependency of NETCoreApp 2.1.
As we are upgrading the code from .NET core 2.1 to .NET core 3.1, we cannot downgrade to NETCoreApp 2.1. Finally, after changing the command to “dotnet tool install --global Amazon.Lambda.Tools”, which makes sure the latest version (5.1.2) is installed. This version of the Amazon.Lambda.Tools package has no dependencies and deployment go smooth fixing the problem.