Moved SQLite related items into a separate project to avoid pulling in the extra content files when using the utility library for mini projects

This commit is contained in:
Kenneth Skovhede
2014-04-07 11:59:33 +02:00
parent 260c18c503
commit 4414c2f0dd
14 changed files with 235 additions and 132 deletions
+8
View File
@@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.CommandLine.Backe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.Backend.GoogleDocs", "Duplicati\Library\Backend\GoogleDocs\Duplicati.Library.Backend.GoogleDocs.csproj", "{42C91180-11EB-4590-82EA-80FE9D4DEBEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.SQLiteHelper", "Duplicati\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj", "{2C838169-B187-4B09-8768-1C24C2521C8D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -104,6 +106,12 @@ Global
{2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Release|Any CPU.Build.0 = Release|Any CPU
{2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{2AF960C0-357D-4D44-A3D5-8B6E89DB0F11}.Test|Any CPU.Build.0 = Debug|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Release|Any CPU.Build.0 = Release|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{2C838169-B187-4B09-8768-1C24C2521C8D}.Test|Any CPU.Build.0 = Debug|Any CPU
{33FD1D24-C28F-4C71-933F-98F1586EA76C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33FD1D24-C28F-4C71-933F-98F1586EA76C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33FD1D24-C28F-4C71-933F-98F1586EA76C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -36,11 +36,11 @@ namespace Duplicati.Library.Main.Database
protected static System.Data.IDbConnection CreateConnection(string path)
{
path = System.IO.Path.GetFullPath(path);
var c = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType);
var c = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType);
if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(path)))
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
Library.Utility.DatabaseUpgrader.UpgradeDatabase(c, path, typeof(LocalDatabase));
Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(c, path, typeof(LocalDatabase));
return c;
}
@@ -141,6 +141,10 @@
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACE}</Project>
<Name>Duplicati.Library.Snapshots</Name>
</ProjectReference>
<ProjectReference Include="..\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
<Project>{2C838169-B187-4B09-8768-1C24C2521C8D}</Project>
<Name>Duplicati.Library.SQLiteHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -79,7 +79,7 @@ namespace Duplicati.Library.Main.Operation
Type sqlite = null;
string sqliteversion = "";
try { sqlite = Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType; }
try { sqlite = Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType; }
catch { }
if (sqlite != null)
@@ -22,7 +22,7 @@ using System.Collections.Generic;
using System.Text;
using System.Data;
namespace Duplicati.Library.Utility
namespace Duplicati.Library.SQLiteHelper
{
/// <summary>
/// This class will read embedded files from the given folder.
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2C838169-B187-4B09-8768-1C24C2521C8D}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Duplicati.Library.SQLiteHelper</RootNamespace>
<AssemblyName>SQLiteHelper</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\GUI\Duplicati.GUI.TrayIcon\Duplicati.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DatabaseUpgrader.cs" />
<Compile Include="SQLiteLoader.cs" />
<Compile Include="Strings\DatabaseUpgrader.Designer.cs">
<DependentUpon>DatabaseUpgrader.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="SQLite\pinvoke\" />
<Folder Include="SQLite\win32\" />
<Folder Include="SQLite\win64\" />
<Folder Include="Strings\" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\thirdparty\SQLite\win64\System.Data.SQLite.dll">
<Link>SQLite\win64\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\thirdparty\SQLite\win32\System.Data.SQLite.dll">
<Link>SQLite\win32\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\thirdparty\SQLite\pinvoke\System.Data.SQLite.dll">
<Link>SQLite\pinvoke\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="Strings\DatabaseUpgrader.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DatabaseUpgrader.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Utility\Duplicati.Library.Utility.csproj">
<Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
<Name>Duplicati.Library.Utility</Name>
</ProjectReference>
</ItemGroup>
</Project>
@@ -0,0 +1,38 @@
// Copyright (C) 2014, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("SQLiteHelper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
@@ -1,93 +1,93 @@
#region Disclaimer / License
// Copyright (C) 2011, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace Duplicati.Library.Utility
{
public static class SQLiteLoader
{
/// <summary>
/// A cached copy of the type
/// </summary>
private static Type m_type = null;
/// <summary>
/// Returns the SQLiteCommand type for the current architecture
/// </summary>
public static Type SQLiteConnectionType
{
get
{
if (m_type == null)
{
string filename = "System.Data.SQLite.dll";
string basePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SQLite");
//Default is to use the pinvoke version which requires a native .dll/.so
string assemblyPath = System.IO.Path.Combine(basePath, "pinvoke");
if (!Duplicati.Library.Utility.Utility.IsMono)
{
//If we run with MS.Net we can use the mixed mode assemblies
if (Library.Utility.Utility.Is64BitProcess)
{
if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win64"), filename)))
assemblyPath = System.IO.Path.Combine(basePath, "win64");
}
else
{
if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win32"), filename)))
assemblyPath = System.IO.Path.Combine(basePath, "win32");
}
} else {
//On Mono, we try to find the Mono version of SQLite
//This secrect commandline variable can be used to support older installations
if (System.Environment.GetEnvironmentVariable("DISABLE_MONO_DATA_SQLITE") == null)
{
try
{
Type t = System.Reflection.Assembly.Load("Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756").GetType("Mono.Data.Sqlite.SqliteConnection");
if (t != null && t.GetInterface("System.Data.IDbConnection", false) != null)
{
Version v = new Version((string)t.GetProperty("SQLiteVersion").GetValue(null, null));
if (v >= new Version(3, 6, 3))
{
m_type = t;
return m_type;
}
}
} catch (Exception ex){
Console.WriteLine(string.Format("Failed to load Mono.Data.Sqlite.SqliteConnection, reverting to built-in.{0} Error message: {1}", Environment.NewLine, ex.ToString()));
}
}
}
m_type = System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(assemblyPath, filename)).GetType("System.Data.SQLite.SQLiteConnection");
}
return m_type;
}
}
}
}
#region Disclaimer / License
// Copyright (C) 2011, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace Duplicati.Library.SQLiteHelper
{
public static class SQLiteLoader
{
/// <summary>
/// A cached copy of the type
/// </summary>
private static Type m_type = null;
/// <summary>
/// Returns the SQLiteCommand type for the current architecture
/// </summary>
public static Type SQLiteConnectionType
{
get
{
if (m_type == null)
{
string filename = "System.Data.SQLite.dll";
string basePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SQLite");
//Default is to use the pinvoke version which requires a native .dll/.so
string assemblyPath = System.IO.Path.Combine(basePath, "pinvoke");
if (!Duplicati.Library.Utility.Utility.IsMono)
{
//If we run with MS.Net we can use the mixed mode assemblies
if (Library.Utility.Utility.Is64BitProcess)
{
if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win64"), filename)))
assemblyPath = System.IO.Path.Combine(basePath, "win64");
}
else
{
if (System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.Combine(basePath, "win32"), filename)))
assemblyPath = System.IO.Path.Combine(basePath, "win32");
}
} else {
//On Mono, we try to find the Mono version of SQLite
//This secrect commandline variable can be used to support older installations
if (System.Environment.GetEnvironmentVariable("DISABLE_MONO_DATA_SQLITE") == null)
{
try
{
Type t = System.Reflection.Assembly.Load("Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756").GetType("Mono.Data.Sqlite.SqliteConnection");
if (t != null && t.GetInterface("System.Data.IDbConnection", false) != null)
{
Version v = new Version((string)t.GetProperty("SQLiteVersion").GetValue(null, null));
if (v >= new Version(3, 6, 3))
{
m_type = t;
return m_type;
}
}
} catch (Exception ex){
Console.WriteLine(string.Format("Failed to load Mono.Data.Sqlite.SqliteConnection, reverting to built-in.{0} Error message: {1}", Environment.NewLine, ex.ToString()));
}
}
}
m_type = System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(assemblyPath, filename)).GetType("System.Data.SQLite.SQLiteConnection");
}
return m_type;
}
}
}
}
@@ -8,7 +8,7 @@
// </autogenerated>
// ------------------------------------------------------------------------------
namespace Duplicati.Library.Utility.Strings {
namespace Duplicati.Library.SQLiteHelper.Strings {
using System;
@@ -29,7 +29,7 @@ namespace Duplicati.Library.Utility.Strings {
internal static System.Resources.ResourceManager ResourceManager {
get {
if (object.Equals(null, resourceMan)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Duplicati.Library.Utility.Strings.DatabaseUpgrader", typeof(DatabaseUpgrader).Assembly);
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Duplicati.Library.SQLiteHelper.Strings.DatabaseUpgrader", typeof(DatabaseUpgrader).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -90,11 +90,6 @@
<Compile Include="WorkerThread.cs" />
<Compile Include="CommandLineParser.cs" />
<Compile Include="BlockingQueue.cs" />
<Compile Include="DatabaseUpgrader.cs" />
<Compile Include="SQLiteLoader.cs" />
<Compile Include="Strings\DatabaseUpgrader.Designer.cs">
<DependentUpon>DatabaseUpgrader.resx</DependentUpon>
</Compile>
<Compile Include="Uri.cs" />
<Compile Include="Strings\Uri.Designer.cs">
<DependentUpon>Uri.resx</DependentUpon>
@@ -142,10 +137,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Uri.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Strings\DatabaseUpgrader.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DatabaseUpgrader.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -155,24 +146,4 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Folder Include="SQLite\" />
<Folder Include="SQLite\pinvoke\" />
<Folder Include="SQLite\win32\" />
<Folder Include="SQLite\win64\" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\thirdparty\SQLite\win64\System.Data.SQLite.dll">
<Link>SQLite\win64\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\thirdparty\SQLite\win32\System.Data.SQLite.dll">
<Link>SQLite\win32\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\thirdparty\SQLite\pinvoke\System.Data.SQLite.dll">
<Link>SQLite\pinvoke\System.Data.SQLite.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
+4
View File
@@ -204,6 +204,10 @@
<Project>{D63E53E4-A458-4C2F-914D-92F715F58ACE}</Project>
<Name>Duplicati.Library.Snapshots</Name>
</ProjectReference>
<ProjectReference Include="..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
<Project>{2C838169-B187-4B09-8768-1C24C2521C8D}</Project>
<Name>Duplicati.Library.SQLiteHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Strings\DuplicatiRunner.resx">
+3 -3
View File
@@ -267,7 +267,7 @@ namespace Duplicati.Server
Duplicati.Library.Logging.Log.CurrentLog = new Duplicati.Library.Logging.StreamLog(commandlineOptions["log-file"]);
}
Version sqliteVersion = new Version((string)Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType.GetProperty("SQLiteVersion").GetValue(null, null));
Version sqliteVersion = new Version((string)Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType.GetProperty("SQLiteVersion").GetValue(null, null));
if (sqliteVersion < new Version(3, 6, 3))
{
if (writeConsole)
@@ -283,7 +283,7 @@ namespace Duplicati.Server
}
//Create the connection instance
System.Data.IDbConnection con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType);
System.Data.IDbConnection con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType);
try
{
@@ -302,7 +302,7 @@ namespace Duplicati.Server
//Attempt to open the database, handling any encryption present
OpenDatabase(con);
Duplicati.Library.Utility.DatabaseUpgrader.UpgradeDatabase(con, DatabasePath, typeof(Duplicati.Server.Database.Connection));
Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(con, DatabasePath, typeof(Duplicati.Server.Database.Connection));
}
catch (Exception ex)
{
+1 -1
View File
@@ -399,7 +399,7 @@ namespace Duplicati.Server
return;
}
using(var con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType))
using(var con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType))
{
con.ConnectionString = "Data Source=" + backup.DBPath;
con.Open();