如何在WP8项目中使用Sqlite而不引用Sqlite扩展

时间:2015-01-13 09:39:33

标签: sqlite windows-phone-8

我的Windows Phone 8应用程序中的Sqlite存在问题。我按照了因果指南,你必须添加 sqlite-net sqlite-net-wp8 NuGet包,然后添加编译参数 USE_WP8_NATIVE_SQLITE 和然后添加指向 Sqlite for Windows Phone Visual Studio Extension的链接。

我在最后一步遇到问题,因为它需要安装特定的Visual Studio扩展,因此它不符合我们要求在Git存储库中包含所有源文件和库,而不需要在运行Continuous时安装任何其他插件为新开发人员集成或设置计算机。

当我尝试添加对位于
的sqlite3.dll的引用时 C:\ Program Files(x86)\ Microsoft SDKs \ Windows Phone \ v8.0 \ ExtensionSDKs \ SQLite.WP80 \ 3.8.7.4 \ Redist \ Retail \ x86 \ sqlite3.dll
我收到错误“无法将对更高版本或不兼容程序集的引用添加到项目中。”

有没有办法解决这个问题,并在我的Git存储库中拥有所有必需的Sqlite库,而不需要引用需要安装的VS Extensions?

2 个答案:

答案 0 :(得分:0)

我知道这是旧的,但我最近做了类似的事情。这是我采取的方法:

  1. 安装扩展程序,然后从C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\ExtensionSDKs\SQLite.WP80复制文件并复制到$(SolutionDir)packages目录

  2. 编辑包中包含的$(SolutionDir)packages\DesignTime\CommonConfiguration\neutral\SQLite.WP80.props文件并更改IncludePath和LibraryPath的路径:

  3. <IncludePath>$(SolutionDir)packages\SQLite.WP80\latest\DesignTime\CommonConfiguration\Neutral;$(IncludePath)</IncludePath>

    <LibraryPath>$(SolutionDir)packages\SQLite.WP80\latest\DesignTime\$(PackageConfiguration)\$(PlatformTarget);$(LibraryPath)</LibraryPath>

    1. 修改SQLite.vcxproj文件 A.添加属性组以添加sqlite3.dll的位置
    2. `

      <PropertyGroup>
          <SQLiteBase>$(SolutionDir)packages\SQLite.WP80\latest\Redist</SQLiteBase>
          <SQLiteWin32Debug>$(SQLiteBase)\Debug\x86</SQLiteWin32Debug>
          <SQLiteWin32Release>$(SQLiteBase)\Retail\x86</SQLiteWin32Release>
          <SQLiteArmDebug>$(SQLiteBase)\Debug\ARM</SQLiteArmDebug>
          <SQLiteArmRelease>$(SQLiteBase)\Retail\ARM</SQLiteArmRelease>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
          <SQLiteBinPath>$(SQLiteWin32Debug)</SQLiteBinPath>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
          <SQLiteBinPath>$(SQLiteWin32Release)</SQLiteBinPath>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
          <SQLiteBinPath>$(SQLiteWin32Debug)</SQLiteBinPath>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
          <SQLiteBinPath>$(SQLiteWin32Release)</SQLiteBinPath>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
          <SQLiteBinPath>$(SQLiteArmDebug)</SQLiteBinPath>
        </PropertyGroup>
        <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
          <SQLiteBinPath>$(SQLiteArmRelease)</SQLiteBinPath>
        </PropertyGroup>
      

      `

      B中。更改props文件的ImportGroup以引用解决方案中的路径:

      <ImportGroup Label="PropertySheets"> <Import Project="$(SolutionDir)packages\SQLite.WP80\version\DesignTime\CommonConfiguration\Neutral\SQLite.WP80.props" /> </ImportGroup>

      ℃。更改它引用SDK的ItemGroup并更改它以添加sqlite3.dll

      <ItemGroup> <CustomBuild Include="$(SQLiteBinPath)\sqlite3.dll"> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> </CustomBuild> </ItemGroup>

答案 1 :(得分:0)

使用此扩展程序https://visualstudiogallery.msdn.microsoft.com/1f027247-1e01-4ec6-8f5b-70dabb375217“本地”复制SQLite SDK文件。