aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.BuildTasks/GetCabList.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-07-19 00:58:00 -0700
committerRob Mensching <rob@firegiant.com>2018-07-21 07:36:59 -0700
commit2724cfee4c163f3297ee25edfd2372767cfd4945 (patch)
tree8cdda34c83bea014a586a491e3b4b187ad8f16da /src/WixToolset.BuildTasks/GetCabList.cs
parent4d40bef9cf51b8cff7e1f6a73fdf68b9722eb8a0 (diff)
downloadwix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.gz
wix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.bz2
wix-2724cfee4c163f3297ee25edfd2372767cfd4945.zip
Move tool projects to Tools repo
Diffstat (limited to 'src/WixToolset.BuildTasks/GetCabList.cs')
-rw-r--r--src/WixToolset.BuildTasks/GetCabList.cs87
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
3namespace 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}