summaryrefslogtreecommitdiff
path: root/src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs')
-rw-r--r--src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs80
1 files changed, 65 insertions, 15 deletions
diff --git a/src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs b/src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs
index d701da20..d9239f10 100644
--- a/src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs
+++ b/src/dtf/WixToolset.Dtf.MakeSfxCA/MakeSfxCA.cs
@@ -3,11 +3,12 @@
3namespace WixToolset.Dtf.MakeSfxCA 3namespace WixToolset.Dtf.MakeSfxCA
4{ 4{
5 using System; 5 using System;
6 using System.IO;
7 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO;
8 using System.Linq;
9 using System.Reflection;
8 using System.Security; 10 using System.Security;
9 using System.Text; 11 using System.Text;
10 using System.Reflection;
11 using WixToolset.Dtf.Compression; 12 using WixToolset.Dtf.Compression;
12 using WixToolset.Dtf.Compression.Cab; 13 using WixToolset.Dtf.Compression.Cab;
13 using WixToolset.Dtf.Resources; 14 using WixToolset.Dtf.Resources;
@@ -28,12 +29,12 @@ namespace WixToolset.Dtf.MakeSfxCA
28 /// Prints usage text for the tool. 29 /// Prints usage text for the tool.
29 /// </summary> 30 /// </summary>
30 /// <param name="w">Console text writer.</param> 31 /// <param name="w">Console text writer.</param>
31 public static void Usage(TextWriter w) 32 private static void Usage(TextWriter w)
32 { 33 {
33 w.WriteLine("WiX Toolset custom action packager version {0}", Assembly.GetExecutingAssembly().GetName().Version); 34 w.WriteLine("WiX Toolset custom action packager version {0}", Assembly.GetExecutingAssembly().GetName().Version);
34 w.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved."); 35 w.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved.");
35 w.WriteLine(); 36 w.WriteLine();
36 w.WriteLine("Usage: WixToolset.Dtf.MakeSfxCA <outputca.dll> SfxCA.dll <inputca.dll> [support files ...]"); 37 w.WriteLine("Usage: WixToolset.Dtf.MakeSfxCA [-v] <outputca.dll> SfxCA.dll <inputca.dll> [support files ...]");
37 w.WriteLine(); 38 w.WriteLine();
38 w.WriteLine("Makes a self-extracting managed MSI CA or UI DLL package."); 39 w.WriteLine("Makes a self-extracting managed MSI CA or UI DLL package.");
39 w.WriteLine("Support files must include " + MakeSfxCA.REQUIRED_WI_ASSEMBLY); 40 w.WriteLine("Support files must include " + MakeSfxCA.REQUIRED_WI_ASSEMBLY);
@@ -47,20 +48,42 @@ namespace WixToolset.Dtf.MakeSfxCA
47 /// <returns>0 on success, nonzero on failure.</returns> 48 /// <returns>0 on success, nonzero on failure.</returns>
48 public static int Main(string[] args) 49 public static int Main(string[] args)
49 { 50 {
50 if (args.Length < 3) 51 var logger = TextWriter.Null;
52 var output = String.Empty;
53 var sfxDll = String.Empty;
54 var inputs = new List<string>();
55
56 var expandedArgs = ExpandArguments(args);
57
58 foreach (var arg in expandedArgs)
59 {
60 if (arg == "-v")
61 {
62 logger = Console.Out;
63 }
64 else if (String.IsNullOrEmpty(output))
65 {
66 output = arg;
67 }
68 else if (String.IsNullOrEmpty(sfxDll))
69 {
70 sfxDll = arg;
71 }
72 else
73 {
74 inputs.Add(arg);
75 }
76 }
77
78 if (inputs.Count == 0)
51 { 79 {
52 Usage(Console.Out); 80 Usage(Console.Out);
53 return 1; 81 return 1;
54 } 82 }
55 83
56 var output = args[0];
57 var sfxDll = args[1];
58 var inputs = new string[args.Length - 2];
59 Array.Copy(args, 2, inputs, 0, inputs.Length);
60
61 try 84 try
62 { 85 {
63 Build(output, sfxDll, inputs, Console.Out); 86 Build(output, sfxDll, inputs, logger);
64 return 0; 87 return 0;
65 } 88 }
66 catch (ArgumentException ex) 89 catch (ArgumentException ex)
@@ -81,11 +104,38 @@ namespace WixToolset.Dtf.MakeSfxCA
81 } 104 }
82 105
83 /// <summary> 106 /// <summary>
107 /// Read the arguments include parsing response files.
108 /// </summary>
109 /// <param name="args">Arguments to expand</param>
110 /// <returns>Expanded list of arguments</returns>
111 private static List<string> ExpandArguments(string[] args)
112 {
113 var result = new List<string>(args.Length);
114 foreach (var arg in args)
115 {
116 if (String.IsNullOrWhiteSpace(arg))
117 {
118 }
119 else if (arg.StartsWith("@"))
120 {
121 var parsed = File.ReadAllLines(arg.Substring(1));
122 result.AddRange(parsed.Select(p => p.Trim('"')).Where(p => !String.IsNullOrWhiteSpace(p)));
123 }
124 else
125 {
126 result.Add(arg);
127 }
128 }
129
130 return result;
131 }
132
133 /// <summary>
84 /// Packages up all the inputs to the output location. 134 /// Packages up all the inputs to the output location.
85 /// </summary> 135 /// </summary>
86 /// <exception cref="Exception">Various exceptions are thrown 136 /// <exception cref="Exception">Various exceptions are thrown
87 /// if things go wrong.</exception> 137 /// if things go wrong.</exception>
88 public static void Build(string output, string sfxDll, IList<string> inputs, TextWriter log) 138 private static void Build(string output, string sfxDll, IList<string> inputs, TextWriter log)
89 { 139 {
90 MakeSfxCA.log = log; 140 MakeSfxCA.log = log;
91 141
@@ -205,7 +255,7 @@ namespace WixToolset.Dtf.MakeSfxCA
205 /// </remarks> 255 /// </remarks>
206 private static void ResolveDependentAssemblies(IDictionary<string, string> inputFiles, string inputDir) 256 private static void ResolveDependentAssemblies(IDictionary<string, string> inputFiles, string inputDir)
207 { 257 {
208 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) 258 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate (object sender, ResolveEventArgs args)
209 { 259 {
210 AssemblyName resolveName = new AssemblyName(args.Name); 260 AssemblyName resolveName = new AssemblyName(args.Name);
211 Assembly assembly = null; 261 Assembly assembly = null;
@@ -416,7 +466,7 @@ namespace WixToolset.Dtf.MakeSfxCA
416 foreach (var argument in attribute.ConstructorArguments) 466 foreach (var argument in attribute.ConstructorArguments)
417 { 467 {
418 // The entry point name is the first positional argument, if specified. 468 // The entry point name is the first positional argument, if specified.
419 entryPointName = (string) argument.Value; 469 entryPointName = (string)argument.Value;
420 break; 470 break;
421 } 471 }
422 472
@@ -472,7 +522,7 @@ namespace WixToolset.Dtf.MakeSfxCA
472 byte[] fileBytes; 522 byte[] fileBytes;
473 using (var readStream = File.OpenRead(sfxDll)) 523 using (var readStream = File.OpenRead(sfxDll))
474 { 524 {
475 fileBytes = new byte[(int) readStream.Length]; 525 fileBytes = new byte[(int)readStream.Length];
476 readStream.Read(fileBytes, 0, fileBytes.Length); 526 readStream.Read(fileBytes, 0, fileBytes.Length);
477 } 527 }
478 528