当引用的项目需要时,SQLite.Interop.dll文件不会复制到项目输出路径

Ben*_*mps 14 sqlite system.data.sqlite nuget

我在Visual Studio 2015中使用System.Data.SQLite核心版本:1.0.98.1 nuget包.当我构建引用我的System.Data.SQLite包的项目时,它复制两个文件夹(x86和x64),每个文件夹包含一个SQLite .Interop.dll到输出目录.但是,当我构建我的测试项目或任何其他引用前面提到的项目的项目时,这些文件夹不会被复制到父项目的输出目录,并且我在SQLite.Interop.dll上得到一个DllNotFoundException.

注意:特别是当引用System.Data.SQLite的项目被另一个项目引用时

Ben*_*mps 30

作为doumented的recomended解决方案在这里是你的包创建System.Data.SQLite.Core.targets.user\System.Data.SQLite.Core.1.0.98.1 \构建包含\ [这里你的框架版本]文件夹

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup> 
        <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
        <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
        <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
        <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
    </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

但是,如果您不想将packages文件夹中的任何内容添加到源代码管理中,则可以直接将以下内容添加到项目文件中

<PropertyGroup> 
    <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
    <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
    <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
    <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

  • 我的本地构建工作正常 - CopySQLiteInteropFiles运行并将文件复制到我的机器上的OutDir.但是在我对TeamCity的测试中,同样的构建失败了 - 在找不到的Interop文件上没有找到异常.在我的proj文件中创建CopySQLiteInteropFiles属性是为了让TeamCity复制interop文件.+1 (2认同)
  • 第二种解决方案对我来说很棒。从nuget获得新版本后,建议的休息时间不是吗? (2认同)