diff options
Diffstat (limited to 'src/WixToolset.BuildTasks/GetCabList.cs')
-rw-r--r-- | src/WixToolset.BuildTasks/GetCabList.cs | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/WixToolset.BuildTasks/GetCabList.cs b/src/WixToolset.BuildTasks/GetCabList.cs deleted file mode 100644 index e97538af..00000000 --- a/src/WixToolset.BuildTasks/GetCabList.cs +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.BuildTasks | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | using System.Diagnostics; | ||
9 | using System.IO; | ||
10 | using System.Reflection; | ||
11 | using System.Xml; | ||
12 | using Microsoft.Build.Framework; | ||
13 | using Microsoft.Build.Utilities; | ||
14 | using WixToolset.Dtf.WindowsInstaller; | ||
15 | using Microsoft.Win32; | ||
16 | |||
17 | /// <summary> | ||
18 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
19 | /// WixLocalization element inside the file. | ||
20 | /// </summary> | ||
21 | public class GetCabList : Task | ||
22 | { | ||
23 | private ITaskItem database; | ||
24 | private ITaskItem[] cabList; | ||
25 | |||
26 | /// <summary> | ||
27 | /// The list of database files to find cabs in | ||
28 | /// </summary> | ||
29 | [Required] | ||
30 | public ITaskItem Database | ||
31 | { | ||
32 | get { return this.database; } | ||
33 | set { this.database = value; } | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// The total list of cabs in this database | ||
38 | /// </summary> | ||
39 | [Output] | ||
40 | public ITaskItem[] CabList | ||
41 | { | ||
42 | get { return this.cabList; } | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
47 | /// </summary> | ||
48 | /// <returns>True upon completion of the task execution.</returns> | ||
49 | public override bool Execute() | ||
50 | { | ||
51 | string databaseFile = this.database.ItemSpec; | ||
52 | Object []args = { }; | ||
53 | System.Collections.Generic.List<ITaskItem> cabNames = new System.Collections.Generic.List<ITaskItem>(); | ||
54 | |||
55 | // If the file doesn't exist, no cabs to return, so exit now | ||
56 | if (!File.Exists(databaseFile)) | ||
57 | { | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | using (Database database = new Database(databaseFile)) | ||
62 | { | ||
63 | // If the media table doesn't exist, no cabs to return, so exit now | ||
64 | if (null == database.Tables["Media"]) | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | |||
69 | System.Collections.IList records = database.ExecuteQuery("SELECT `Cabinet` FROM `Media`", args); | ||
70 | |||
71 | foreach (string cabName in records) | ||
72 | { | ||
73 | if (String.IsNullOrEmpty(cabName) || cabName.StartsWith("#", StringComparison.Ordinal)) | ||
74 | { | ||
75 | continue; | ||
76 | } | ||
77 | |||
78 | cabNames.Add(new TaskItem(Path.Combine(Path.GetDirectoryName(databaseFile), cabName))); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | this.cabList = cabNames.ToArray(); | ||
83 | |||
84 | return true; | ||
85 | } | ||
86 | } | ||
87 | } | ||