aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-02-05 13:58:02 -0800
committerRob Mensching <rob@firegiant.com>2020-02-05 14:00:46 -0800
commitdfa44dcb277235051654fe4e951d957b5e3f9dc6 (patch)
tree969557ed40753765bfee48271251d5a352865db7 /src
parent4d4e7acb6255676337b0f4f0ee4d590ba31357b7 (diff)
downloadwix-dfa44dcb277235051654fe4e951d957b5e3f9dc6.tar.gz
wix-dfa44dcb277235051654fe4e951d957b5e3f9dc6.tar.bz2
wix-dfa44dcb277235051654fe4e951d957b5e3f9dc6.zip
Add query mechanisms for useful for patching and cabinets
Diffstat (limited to 'src')
-rw-r--r--src/WixBuildTools.TestSupport/Query.cs68
-rw-r--r--src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj4
2 files changed, 70 insertions, 2 deletions
diff --git a/src/WixBuildTools.TestSupport/Query.cs b/src/WixBuildTools.TestSupport/Query.cs
index a5883067..bbd9f89a 100644
--- a/src/WixBuildTools.TestSupport/Query.cs
+++ b/src/WixBuildTools.TestSupport/Query.cs
@@ -4,7 +4,10 @@ namespace WixBuildTools.TestSupport
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO;
8 using System.Linq;
7 using System.Text; 9 using System.Text;
10 using WixToolset.Dtf.Compression.Cab;
8 using WixToolset.Dtf.WindowsInstaller; 11 using WixToolset.Dtf.WindowsInstaller;
9 12
10 public class Query 13 public class Query
@@ -25,7 +28,7 @@ namespace WixBuildTools.TestSupport
25 continue; 28 continue;
26 } 29 }
27 30
28 using (var view = db.OpenView($"SELECT * FROM `{table}`")) 31 using (var view = db.OpenView("SELECT * FROM `{0}`", table))
29 { 32 {
30 view.Execute(); 33 view.Execute();
31 34
@@ -58,5 +61,68 @@ namespace WixBuildTools.TestSupport
58 results.Sort(); 61 results.Sort();
59 return results.ToArray(); 62 return results.ToArray();
60 } 63 }
64
65 public static CabFileInfo[] GetCabinetFiles(string path)
66 {
67 var cab = new CabInfo(path);
68
69 var result = cab.GetFiles();
70
71 return result.Select(c => c).ToArray();
72 }
73
74 public static void ExtractStream(string path, string streamName, string outputPath)
75 {
76 Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
77
78 using (var db = new Database(path))
79 using (var view = db.OpenView("SELECT `Data` FROM `_Streams` WHERE `Name` = '{0}'", streamName))
80 {
81 view.Execute();
82
83 using (var record = view.Fetch())
84 {
85 record.GetStream(1, outputPath);
86 }
87 }
88 }
89
90 public static void ExtractSubStorage(string path, string subStorageName, string outputPath)
91 {
92 Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
93
94 using (var db = new Database(path))
95 using (var view = db.OpenView("SELECT `Name`, `Data` FROM `_Storages` WHERE `Name` = '{0}'", subStorageName))
96 {
97 view.Execute();
98
99 using (var record = view.Fetch())
100 {
101 var name = record.GetString(1);
102 record.GetStream(2, outputPath);
103 }
104 }
105 }
106
107 public static string[] GetSubStorageNames(string path)
108 {
109 var result = new List<string>();
110
111 using (var db = new Database(path))
112 using (var view = db.OpenView("SELECT `Name` FROM `_Storages`"))
113 {
114 view.Execute();
115
116 Record record;
117 while ((record = view.Fetch()) != null)
118 {
119 var name = record.GetString(1);
120 result.Add(name);
121 }
122 }
123
124 result.Sort();
125 return result.ToArray();
126 }
61 } 127 }
62} 128}
diff --git a/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj
index 782a0217..31bdf033 100644
--- a/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj
+++ b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj
@@ -4,7 +4,7 @@
4<Project Sdk="Microsoft.NET.Sdk"> 4<Project Sdk="Microsoft.NET.Sdk">
5 5
6 <PropertyGroup> 6 <PropertyGroup>
7 <TargetFramework>netstandard2.0</TargetFramework> 7 <TargetFrameworks>netstandard2.0;net461;net472</TargetFrameworks>
8 <IsPackable>true</IsPackable> 8 <IsPackable>true</IsPackable>
9 <DebugType>embedded</DebugType> 9 <DebugType>embedded</DebugType>
10 <PublishRepositoryUrl>true</PublishRepositoryUrl> 10 <PublishRepositoryUrl>true</PublishRepositoryUrl>
@@ -13,6 +13,8 @@
13 <ItemGroup> 13 <ItemGroup>
14 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" /> 14 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" />
15 <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" NoWarn="NU1701" /> 15 <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" NoWarn="NU1701" />
16 <PackageReference Include="WixToolset.Dtf.Compression" Version="4.0.*" NoWarn="NU1701" />
17 <PackageReference Include="WixToolset.Dtf.Compression.Cab" Version="4.0.*" NoWarn="NU1701" />
16 </ItemGroup> 18 </ItemGroup>
17 19
18 <ItemGroup> 20 <ItemGroup>