1

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?

LandonC
  • 889
  • 1
  • 16
  • 28
  • Currently how are you referencing `AWSSDK.SimpleSystemsManagement` in your project? – Chetan Mar 20 '18 at 03:31
  • @ChetanRanpariya I added the reference to one of my .NET 4.5 projects via NuGet, so just the standard way. – LandonC Mar 21 '18 at 00:21
  • I noticed that my "secondary" references, although zipped and deployed, are not in MyProject.deps.json, which I'm guessing is why they're not available. – LandonC Mar 22 '18 at 04:00

1 Answers1

0

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.

LandonC
  • 889
  • 1
  • 16
  • 28