2
votes

I have a .NET Core Lambda function which fails to build the deployment package for AWS Lambda, using the dotnet lambda utility. This function was previously .NET Core 1.0, and I have had to upgrade it to .NET Core 3.1 as 1.0 is no longer supported. Using AWS Toolkit for Visual Studio to deploy to AWS works fine, and targets .NET Core 3.1 correctly. I have updated my tools / defaults .json to target Core 3.1 and the project properties to do the same.

For this exercise though, I need to build a deployment zip separately to uploading it, and the utility fails to build it. It's like it still has a reference to .net core 1.0 somewhere?

Command:

$ dotnet lambda package -c Release -o erececipt_lambda_trigger.zip -f netcoreapp3.1

Error:

It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '1.0.0' was not found.

  • The following frameworks were found: 2.1.16 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.2.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

I followed the link, which is dead of course, but I found a way to download and install .NET Core 1.0 using PowerShell:

PS C:\> .\dotnet-install.ps1 -Channel 1.0
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/1.1.11/dotnet-sdk-1.1.11-win-x64.zip
dotnet-install: Cannot download: https://dotnetcli.azureedge.net/dotnet/Sdk/1.1.11/dotnet-sdk-1.1.11-win-x64.zip
dotnet-install: Downloading legacy link: https://dotnetcli.azureedge.net/dotnet/Sdk/1.1.11/dotnet-dev-win-x64.1.1.11.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/1.1.11/dotnet-dev-win-x64.1.1.11.zip
dotnet-install: Adding to current process PATH: "C:\Users\JMatson\AppData\Local\Microsoft\dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished

But still, the lambda utility fails with the same error. What can I do? My .csproj file is as follows:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Globals">
    <SccProjectName></SccProjectName>
    <SccProvider></SccProvider>
    <SccAuxPath></SccAuxPath>
    <SccLocalPath></SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
    <FileVersion>2.0.0.0</FileVersion>
    <Version>2.0.0</Version>
    <Description>Lambda function for converting receipt control files into HTML email messages.</Description>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.7.0" />
    <PackageReference Include="Amazon.Lambda.S3Events" Version="1.1.0" />
    <PackageReference Include="AWSSDK.S3" Version="3.3.111.21" />
    <PackageReference Include="AWSSDK.SimpleEmail" Version="3.3.101.174" />
    <PackageReference Include="AWSSDK.SimpleSystemsManagement" Version="3.3.126.8" />
    <PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
    <PackageReference Include="SqlKata" Version="2.2.0" />
    <PackageReference Include="SqlKata.Execution" Version="2.2.0" />
    <PackageReference Include="system.data.common" Version="4.3.0" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
    <PackageReference Include="Microsoft.NETCore.Targets" Version="3.0.0" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.7.0" />
  </ItemGroup>
</Project>
1
Your .csproj file doesn't look correct, DotNetCliToolReference seems to be invalid, according to migration guidePavel Anikhouski
This was the issue. Removing that reference allowed the project to be built. You should make this an answer to the question Pavel?JamesMatson
I don't think that it's an answer, it's just a link to aws lambda tool migrationPavel Anikhouski
I have posted the exact/specific answer.JamesMatson

1 Answers

0
votes

Removal of

  <ItemGroup>
    <DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.7.0" />
  </ItemGroup>

Allowed the lambda package tool to work, as this entry in the .csproj file is a holdover from earlier versions of the Lambda tools (likely from when this project was .NET Core 1.0).