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:
"errorMessage": "Could not load file or assembly 'HtmlAgilityPack, Version=126.96.36.199,
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?