0

我已经尝试在这里遵循此线程中的所有选项:基于操作系统的不同 NuGet 包

我在 Windows 10 下使用 WSL2 和 Debian 来构建和测试我的项目。

无论我引用哪个包,我都能构建,但是当我尝试运行测试时,我一直收到错误“无法加载共享库'db2app64.dll'或其依赖项之一。为了帮助诊断加载问题,考虑设置LD_DEBUG环境变量:libdb2app64.dll:无法打开共享对象文件:没有这样的文件或目录”

根据我的研究,当您使用错误版本的软件包时会发生此错误,例如 IBM.Data.DB2.Core,它适用于 Windows,并尝试在 linux 上运行。

顺便说一句,我的项目是多目标的,我尝试了从条件到选择的所有方法。

我没有使用 MSBuild 文件,而是在我的 csproj 中使用 Microsoft.SDK 项目 XML。

这是我的项目文件的一部分:

<ItemGroup Condition="'$(TargetFramework)' != 'net461'">
    <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.110" />
    <PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
    <PackageReference Include="System.Data.SQLite.Core" version="1.0.113.7" />

    <!--<PackageReference Include="IBM.Data.DB2.Core-lnx" Version="2.2.0.100" Condition="'$(OSTYPE)' == 'linux-gnu'" />
    <PackageReference Include="IBM.Data.DB2.Core-osx" Version="2.2.0.100" Condition="'$(OSTYPE)' == 'darwin18'"/>
    <PackageReference Include="IBM.Data.DB2.Core" Version="2.2.0.100"  Condition="'$(OSTYPE)' != 'linux-gnu' AND '$(OSTYPE)' != 'darwin18'" />-->
</ItemGroup>

<!--<ItemGroup Condition="'$(TargetFramework)' != 'net461' and $(IsWindows) == true ">
    <PackageReference Include="IBM.Data.DB2.Core" version="2.2.0.100" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net461' and $(IsLinux) == true ">
    <PackageReference Include="IBM.Data.DB2.Core-lnx" version="2.2.0.100" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net461' and $(IsOSX) == true ">
    <PackageReference Include="IBM.Data.DB2.Core-osx" version="2.2.0.100" />
</ItemGroup>-->

<Choose>
    <When Condition="'$(TargetFramework)' != 'net461' and $(RuntimeIdentifier) != ''">
        <ItemGroup>
            <PackageReference Condition="$(RuntimeIdentifier.StartsWith('win'))" Include="IBM.Data.DB2.Core" Version="2.2.0.100" />
            <PackageReference Condition="$(RuntimeIdentifier.StartsWith('osx'))" Include="IBM.Data.DB2.Core-osx" Version="2.2.0.100" />
            <PackageReference Condition="$(RuntimeIdentifier.StartsWith('linux'))" Include="IBM.Data.DB2.Core-lnx" Version="2.2.0.100" />
        </ItemGroup>
    </When>
    <When Condition="'$(TargetFramework)' != 'net461'">
        <ItemGroup>
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="IBM.Data.DB2.Core" Version="2.2.0.100" />
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="IBM.Data.DB2.Core-osx" Version="2.2.0.100" />
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="IBM.Data.DB2.Core-lnx" Version="2.2.0.100" />
        </ItemGroup>
    </When>
    <!--<Otherwise>
        <ItemGroup>
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="IBM.Data.DB2.Core" Version="2.2.0.100" />
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="IBM.Data.DB2.Core-osx" Version="2.2.0.100" />
            <PackageReference Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="IBM.Data.DB2.Core-lnx" Version="2.2.0.100" />
        </ItemGroup>
    </Otherwise>-->
</Choose>

注释部分是我已经测试过的选项。

有人知道吗?

4

0 回答 0