aws-extensions-for-dotnet-cli icon indicating copy to clipboard operation
aws-extensions-for-dotnet-cli copied to clipboard

Optimised layer fail. Dependency issue.

Open kabzit13 opened this issue 3 years ago • 5 comments

Description

dotnet lambda publish-layer command failing when parameter --enable-package-optimization equals true.

... store: Error: Could not load file or assembly 'System.ComponentModel.Annotations, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

The same set of NuGet packs successfully working on lambda runtime. Layer published successfully if --enable-package-optimization equals false.

Reproduction Steps

Execute command dotnet lambda publish-layer search-common-core --framework netcoreapp3.1 --layer-type runtime-package-store --s3-bucket my-bucket-name --package-manifest ./manifest.xml --enable-package-optimization true

manifest.txt Change extension. Change S3 bucket.

Logs

logs.txt

Environment

  • OS Info: AmazonLinux, ami-087c17d1fe0178315
  • Build Environment: Dotnet sdk version 3.1.413, Lambda tools version 5.1.4

This is a :bug: bug-report

kabzit13 avatar Sep 22 '21 11:09 kabzit13

Hi @kabzit13,

Good morning.

Please share the sample code solution (including the .csproj file) for reproducing the issue.

Thanks, Ashish

ashishdhingra avatar Sep 22 '21 16:09 ashishdhingra

I am not able to share my project, but attached manifest file should be enought to reproduce an issue. I am not uploading solution to EC2 instance, where I am building layer.

kabzit13 avatar Sep 22 '21 16:09 kabzit13

Hi @kabzit13,

Good afternoon.

I was able to reproduce the issue on Amazon Linux using simple Lambda function project and your manifest file, and then executing the above dotnet lambda publish-layer command on Amazon Linux 2 instance. However, I'm not sure if this is a .NET CLI Lambda extensions issue since the dotnet lambda publish-layer command invokes dotnet store internally and enables package optimization by not adding --skip-optimization to the target command.

I could see that Microsoft.EntityFrameworkCore has a dependency on System.ComponentModel.Annotations. Have you tried posting the question to Microsoft's .NET repository? There is a similar issue reported https://github.com/dotnet/runtime/issues/27975, which might help you to get some lead. Also, could you try removing references to Microsoft.EntityFrameworkCore assemblies from your project/manifest and see if it resolves the issue.

I will try to do some research and if required, have team look into it.

Thanks, Ashish

ashishdhingra avatar Sep 23 '21 21:09 ashishdhingra

Hello,

Thanks for your feedback. I have not posted to them.

I have tried to exclude dependencies one by one and found out that there are not only one causing this issue. And not only because of System.ComponentModel.Annotations.

<PackageReference Include="NEST" Version="7.10.1" />
<PackageReference Include="NEST.JsonNetSerializer" Version="7.10.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    <PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />

I will try to raise this issue on dotnet repo.

Maybe you know, are when able to use part of dependencies from layer, and part from the uploaded pack on lambda deploy?

kabzit13 avatar Sep 24 '21 10:09 kabzit13

This seems to be same issue I reported in #167

carlin-q-scott avatar May 02 '22 22:05 carlin-q-scott