2015-09-17 69 views
5

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

注:这是专门在项目引用System.Data.SQLite是由另一个项目

回答

16

的recomended解决方案doumented here是建立在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> 

文件夹,但如果你不想在你的包文件夹中添加任何你的源代码控制,您可以直接将以下内容添加到您的项目文件中

<PropertyGroup> 
    <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles> 
    <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles> 
    <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles> 
    <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles> 
</PropertyGroup> 
+1

我的本地版本工作正常 - CopySQLiteInteropFiles运行并将文件复制到我机器上的OutDir。但是,在我对TeamCity进行测试期间,相同的构建失败 - 没有找到缺少Interop文件的例外。 在我的proj文件中创建CopySQLiteInteropFiles属性是让TeamCity复制互操作文件的原因。 +1 –

+0

第二种解决方案对我很好。刚刚从nuget获得新版本时不建议中断吗? – quarkonium

相关问题