我有一个.NET Core 2.1 Lambda函数。csproj文件是这样的。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<None Remove="chromium.br" />
</ItemGroup>
<ItemGroup>
<Content Include="chromium.br">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="amazon.lambda.logging.aspnetcore" Version="3.0.0" />
<PackageReference Include="amazon.lambda.serialization.json" Version="1.7.0" />
<PackageReference Include="microsoft.extensions.dependencyinjection" Version="3.1.3" />
<PackageReference Include="microsoft.extensions.logging" Version="3.1.3" />
<PackageReference Include="mono.posix.NETStandard" Version="1.0.0" />
<PackageReference Include="puppeteersharp" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="HeadlessChromium.Puppeteer.Lambda.Dotnet">
<HintPath>..\HeadlessChromium.Puppeteer.Lambda.Dotnet\HeadlessChromium.Puppeteer.Lambda.Dotnet.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
项目编译了,但在运行时(即在Lambda环境中),应用程序出现了失败的消息。
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified
我如何纠正这个问题?
我意识到,我使用的HeadlessChromium.Puppeteer.Lambda.Dotnet.dll是针对.NET标准2.1编译的。使用.NET Core 2.1 DLL反而解决了这个问题。