Why NET for AWS Lambda Dependencies not Publishing

0 votes

I have two solutions:

  • One with a single .NET core 2.0 lambda project
  • Another with multiple .NET 4.5 class library projects.

I want to have my lambda method implementation in the 4.5 class libraries so that those functions can be used across the enterprise, not just by the Lambda function. However, when I build my lambda project and publish it from VS 2017, it zips, packages, and publishes its direct dependencies and the 4.5 assembly's dependencies, but none of the 4.5 assembly's dependencies are available.

For example, one of my 4.5 projects has a class library that uses HtmlAgilityPack. When I publish from VS 2017, I can see the assembly being zipped for publishing:

Zipping publish folder C:\Data\Dev\MyProject\bin\Release\netcoreapp2.0\publish to C:\Data\Dev\MyProject\bin\Release\netcoreapp2.0\Lambda1.zip
... zipping: Amazon.Lambda.Core.dll
... zipping: Amazon.Lambda.Serialization.Json.dll
... zipping: AWSSDK.Core.dll
... zipping: AWSSDK.Lambda.dll
... zipping: Elasticsearch.Net.dll
... zipping: EntityFramework.dll
... zipping: HtmlAgilityPack.dll

And I can see the assembly in the ...bin\Release\netcoreapp2.0\publish folder and in the MyProject.zip package. But when I test my lambda, I get the following:

    {
  "errorType": "FileNotFoundException",
  "errorMessage": "Could not load file or assembly 'HtmlAgilityPack, Version=1.4.0.0, 
Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'. The system cannot find the file specified

If I add an HtmlAgilityPack reference directly to my Lambda project, build, and publish, the problem goes away. I don't understand why the file is unavailable when it's clearly in the deployment package. It's like the "secondary" references, those in the 4.5 class libraries, simply aren't available, which makes for some tightly coupled code I'd like to avoid. What am I missing?

Oct 1, 2018 in AWS by bug_seeker
• 15,510 points
1,755 views

1 answer to this question.

0 votes

The answer to this question basically answers this: you can use NuGet packages instead of relative references to make sure the Lambda project is aware of all the transitive dependencies. My real problem is that many of my secondary dependencies in the 4.5 project simply aren't compatible with .NET Core 2.0, which is a completely different issue.

answered Oct 1, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

+3 votes
3 answers
+1 vote
3 answers

Not able to pass params POST to AWS Lambda from Amazon API Gateway

For this template : application/x-www-form-urlencoded  This line below will ...READ MORE

answered Jun 13, 2018 in AWS by Cloud gunner
• 4,670 points
8,750 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
10 answers
+2 votes
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP