0

我们有一个在 Linux 主机上运行的 Azure 函数。
我们的应用程序是一个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)上,该应用程序也可以正常构建,Functions Host 启动并且一切似乎都很好,直到我们找到使用该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/runtimeslinuxWindows。 VS Code 构建结果

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

有谁知道我怎样才能让它再次工作?
我尝试将<RuntimeIdentifier>或添加<RuntimeIdentifiers>到 csproj 中,但这并没有改变任何东西。

4

1 回答 1

4

看起来这是一个在 Grpc.Core 2.34.0 中修复的问题(我相信通过这个提交)。如果您添加对 Grpc.Core 2.34.0 的显式依赖,如下所示:

<PackageReference Include="Grpc.Core" Version="2.34.0" />

...这似乎可以解决它。我仍然不知道为什么运行时被复制到 Windows 而不是 Linux 的“旧”预期位置 - 这感觉就像是 Azure Functions SDK 问题。bin/runtimes但是对于 Grpc.Core 2.34.0,本机扩展加载器“知道”在父目录中的何处找到它。

于 2021-01-19T08:13:00.877 回答