System.Data.SQLite
Check-in [2513e50f9b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:LIBPATH fixes for external tools
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 2513e50f9bee154d27baa38833252f7a292e93f8
User & Date: rmsimpson 2006-04-12 21:11:11
Context
2006-04-13
19:27
Minor updates check-in: 7afc80c36f user: rmsimpson tags: sourceforge
2006-04-12
21:11
LIBPATH fixes for external tools check-in: 2513e50f9b user: rmsimpson tags: sourceforge
05:48
64-bit enhancements check-in: 4ef76f59b4 user: rmsimpson tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/install/InstallDesigner.cs.

435
436
437
438
439
440
441


442
443
444
445
446
447
448
...
718
719
720
721
722
723
724
725




726





































































































































































          }
        }
      }
      catch
      {
        throw;
      }


    }

    private void ReplaceJet(string keyname)
    {
      using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\DataProviders", keyname, _regRoot), true))
      {
        using (RegistryKey source = key.OpenSubKey(oledbDataProviderGuid.ToString("B")))
................................................................................
      }
      string[] values = keySource.GetValueNames();
      for (int n = 0; n < values.Length; n++)
      {
        keyDest.SetValue(values[n], keySource.GetValue(values[n]), keySource.GetValueKind(values[n]));
      }
    }
  }




}












































































































































































>
>







 







|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
          }
        }
      }
      catch
      {
        throw;
      }

      FixXmlLibPaths(install);
    }

    private void ReplaceJet(string keyname)
    {
      using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\DataProviders", keyname, _regRoot), true))
      {
        using (RegistryKey source = key.OpenSubKey(oledbDataProviderGuid.ToString("B")))
................................................................................
      }
      string[] values = keySource.GetValueNames();
      for (int n = 0; n < values.Length; n++)
      {
        keyDest.SetValue(values[n], keySource.GetValue(values[n]), keySource.GetValueKind(values[n]));
      }
    }

    private void FixXmlLibPaths(bool install)
    {
      string installDir = null;
      RegistryKey key = null;

      try
      {
        key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\VisualStudio\\8.0");
        if (key != null)
        {
          try
          {
            installDir = (string)key.GetValue("InstallDir");
          }
          catch
          {
          }
          finally
          {
            if (String.IsNullOrEmpty(installDir))
            {
              ((IDisposable)key).Dispose();
              key = null;
            }
          }
        }

        if (key == null)
        {
          key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\VCExpress\\8.0");
          if (key == null) return;
        }

        try
        {
          installDir = (string)key.GetValue("InstallDir");
        }
        catch
        {
        }
      }
      finally
      {
        if (key != null) ((IDisposable)key).Dispose();
      }

      if (String.IsNullOrEmpty(installDir)) return;

      installDir = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(installDir))), "VC");

      string currentDir;
      string[] lookIn = new string[] { "vcpackages", "bin\\amd64", "bin\\ia64" };
      string sqlitePath = Path.GetDirectoryName(SQLiteLocation);

      foreach (string subfolder in lookIn)
      {
        currentDir = Path.Combine(installDir, subfolder);
        FixXmlLibPaths(currentDir, "VCProjectEngine.DLL*.config", sqlitePath, install);
        FixXmlLibPaths(currentDir, "AMD64.VCPlatform.config", Path.Combine(sqlitePath, "x64"), install);
        FixXmlLibPaths(currentDir, "Itanium.VCPlatform.config", Path.Combine(sqlitePath, "itanium"), install);
        FixXmlLibPaths(currentDir, "WCE.VCPlatform.config", Path.Combine(sqlitePath, "CompactFramework"), install);
      }

      FixLocalUserPaths(install);
    }

    private void FixLocalUserPaths(bool install)
    {
      string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\VisualStudio\\8.0\\VCComponents.dat");
      StringBuilder output = new StringBuilder();
      string line;
      string sqlitePath = Path.GetDirectoryName(SQLiteLocation);
      string currPath = sqlitePath;

      try
      {
        using (StreamReader rd = new StreamReader(file))
        {
          while (rd.EndOfStream == false)
          {
            line = rd.ReadLine();
            line = line.Trim();
            if (String.IsNullOrEmpty(line)) continue;
            if (line[0] == '[')
            {
              if (line.IndexOf("Win32", StringComparison.InvariantCultureIgnoreCase) != -1)
                currPath = sqlitePath;
              else if (line.IndexOf("x64", StringComparison.InvariantCultureIgnoreCase) != -1)
                currPath = Path.Combine(sqlitePath, "x64");
              else if (line.IndexOf("Itanium", StringComparison.InvariantCultureIgnoreCase) != -1)
                currPath = Path.Combine(sqlitePath, "x64");
              else if (line.IndexOf("ARM", StringComparison.InvariantCultureIgnoreCase) != -1)
                currPath = Path.Combine(sqlitePath, "CompactFramework");
            }
            else if (line.StartsWith("Reference Dirs", StringComparison.InvariantCultureIgnoreCase) == true)
            {
              int n = line.IndexOf(";" + currPath, StringComparison.InvariantCultureIgnoreCase);
              if (n > -1) line = line.Remove(n, currPath.Length + 1);

              if (install)
              {
                if (line[line.Length - 1] == '=')
                  line += currPath;
                else
                  line += (";" + currPath);
              }
            }

            output.AppendLine(line);
          }
          rd.Close();
        }

        File.Delete(file);
        using (StreamWriter writer = new StreamWriter(file, false, Encoding.Unicode))
        {          
          writer.Write(output.ToString());
          writer.Close();
        }
      }
      catch
      {
      }
    }

    private void FixXmlLibPaths(string path, string lookFor, string sqlitePath, bool install)
    {
      // Win32
      string[] files = Directory.GetFiles(path, lookFor);
      if (files.Length > 0)
      {
        foreach (string file in files)
        {
          FixXmlLibPath(file, sqlitePath, install);
        }
      }
    }

    private void FixXmlLibPath(string fileName, string sqlitePath, bool install)
    {
      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.PreserveWhitespace = true;
      xmlDoc.Load(fileName);
      
      XmlNodeList xmlNodes = xmlDoc.SelectNodes("VCPlatformConfigurationFile/Platform/Directories");
      if (xmlNodes == null) return;

      foreach(XmlNode xmlNode in xmlNodes)
      {
        string libpath = xmlNode.Attributes.GetNamedItem("Reference").Value;
        if (String.Compare(libpath, sqlitePath, true) == 0)
          libpath = "";
        else
        {
          int n = libpath.IndexOf(";" + sqlitePath, StringComparison.InvariantCultureIgnoreCase);
          if (n > -1) libpath = libpath.Remove(n, sqlitePath.Length + 1);
        }

        if (install)
        {
          if (String.IsNullOrEmpty(libpath)) libpath = sqlitePath;
          else libpath += (";" + sqlitePath);
        }
        xmlNode.Attributes.GetNamedItem("Reference").Value = libpath;
      }

      xmlDoc.Save(fileName);
    }
  }
}