瀏覽代碼

add sqlite config hack

Luke Pulverenti 8 年之前
父節點
當前提交
c869ae746c

+ 8 - 3
MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj

@@ -88,15 +88,16 @@
       <HintPath>..\packages\SQLitePCLRaw.core.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.core.dll</HintPath>
       <Private>True</Private>
     </Reference>
+    <Reference Include="SQLitePCLRaw.provider.sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62684c7b4f184e3f, processorArchitecture=MSIL">
+      <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="MediaBrowser.IsoMounting.Linux">
       <HintPath>..\ThirdParty\MediaBrowser.IsoMounting.Linux\MediaBrowser.IsoMounting.Linux.dll</HintPath>
     </Reference>
     <Reference Include="System.Configuration" />
     <Reference Include="System.Data" />
-    <Reference Include="System.Data.SQLite">
-      <HintPath>..\ThirdParty\SQLitePCLRaw.provider.sqlite3.net45\System.Data.SQLite.dll</HintPath>
-    </Reference>
     <Reference Include="System.IO.Compression" />
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.ServiceModel" />
@@ -222,6 +223,10 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="packages.config" />
+    <None Include="SQLitePCLRaw.provider.sqlite3.dll.config">
+      <SubType>Designer</SubType>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
     <None Include="System.Data.SQLite.dll.config">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <SubType>Designer</SubType>

+ 23 - 2
MediaBrowser.Server.Mono/Program.cs

@@ -35,9 +35,11 @@ namespace MediaBrowser.Server.Mono
 
         public static void Main(string[] args)
         {
-            SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
-
             var applicationPath = Assembly.GetEntryAssembly().Location;
+            var appFolderPath = Path.GetDirectoryName(applicationPath);
+
+            TryCopySqliteConfigFile(appFolderPath);
+            SetSqliteProvider();
 
             var options = new StartupOptions(Environment.GetCommandLineArgs());
 
@@ -68,6 +70,25 @@ namespace MediaBrowser.Server.Mono
             }
         }
 
+        private static void TryCopySqliteConfigFile(string appFolderPath)
+        {
+            try
+            {
+                File.Copy(Path.Combine(appFolderPath, "System.Data.SQLite.dll.config"),
+                    Path.Combine(appFolderPath, "SQLitePCLRaw.provider.sqlite3.dll.config"),
+                    true);
+            }
+            catch
+            {
+                
+            }
+        }
+
+        private static void SetSqliteProvider()
+        {
+            SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
+        }
+
         private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath)
         {
             if (string.IsNullOrEmpty(programDataPath))

+ 1 - 0
MediaBrowser.Server.Mono/packages.config

@@ -6,4 +6,5 @@
   <package id="SharpCompress" version="0.14.0" targetFramework="net46" />
   <package id="SimpleInjector" version="3.2.4" targetFramework="net46" />
   <package id="SQLitePCLRaw.core" version="1.1.1-pre20161109081005" targetFramework="net46" />
+  <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.1-pre20161109081005" targetFramework="net46" />
 </packages>