我们有一个Azure函数在Linux主机上运行。
我们的应用程序是netcoreapp3.1。它运行得很好,除了一个我无法解释的问题。
csproj文件一直是这样配置的(只有一个片段):
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<UserSecretsId>...</UserSecretsId>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Cloud.Asset.V1" Version="2.6.0" />
</ItemGroup>还有很多其他的软件包,但是这个包是有问题的。在Windows上一切都很好,一切都很好。在Linux (或WSL2)上,应用程序也能很好地构建,主机的功能也会启动,而且一切看起来都很好,直到我们看到了使用Google.Cloud.Asset.V1包的代码。此包引用Grpc.Core,然后代码将失败
System.Private.CoreLib: Exception while executing function: inventory. Grpc.Core: Error loading native library. Not found in any of the possible locations: /mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/libgrpc_csharp_ext.x64.so,/mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/runtimes/linux/native/libgrpc_csharp_ext.x64.so,/mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so.对我来说,这似乎没有什么意义,因为这曾经起作用,但最近csproj中除了添加了其他依赖项之外,没有任何改变,但这些依赖与此无关。
签入bin/Debug/netcoreapp3.1/bin/runtimes,这里没有linux,只有Windows。

不过,我在这里确实看到了这个目录,它似乎不在错误消息中的搜索路径中。我是bin/Debug/netcoreapp3.1/runtimes。

有人知道我怎样才能让这件事再起作用吗?
我尝试在csproj中添加<RuntimeIdentifier>或<RuntimeIdentifiers>,但这并没有改变任何事情。
发布于 2021-01-19 08:13:00
看起来这是一个在Grpc.Core 2.34.0中修复的问题(我相信是由此承诺解决的)。如果在Grpc.Core 2.34.0上添加显式依赖项,如下所示:
<PackageReference Include="Grpc.Core" Version="2.34.0" />..。这似乎能解决问题。我仍然不知道为什么运行时被复制到Windows的“旧”预期位置,而不是Linux --这感觉好像是Azure函数SDK的问题。但是使用Grpc.Core 2.34.0,本机扩展加载程序“知道”在父bin/runtimes目录中找到它的位置。
https://stackoverflow.com/questions/65774297
复制相似问题