main
cs 66 lines 1.88 KB
Raw
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 WixToolsetTest.TestCA
4 {
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using System.Linq;
9 using System.Text;
10 using WixToolset.Dtf.WindowsInstaller;
11
12 public class CustomActions
13 {
14 [CustomAction]
15 public static ActionResult ImmediateCA(Session session)
16 {
17 session.Log("Begin ImmediateCA");
18
19 var path = Path.Combine(Path.GetTempPath(), "ImmediateCA.txt");
20 WriteNow(path);
21
22 return ActionResult.Success;
23 }
24
25 [CustomAction]
26 public static ActionResult ExecuteImmediateCA(Session session)
27 {
28 session.Log("Begin ExecuteImmediateCA");
29
30 var path = Path.Combine(Path.GetTempPath(), "ExecuteImmediateCA.txt");
31 WriteNow(path);
32
33 return ActionResult.Success;
34 }
35
36 [CustomAction]
37 public static ActionResult ImpersonatedDeferredCA(Session session)
38 {
39 session.Log("Begin ImpersonatedDeferredCA");
40
41 var path = Path.Combine(Path.GetTempPath(), "ImpersonatedDeferredCA.txt");
42 WriteNow(path);
43
44 return ActionResult.Success;
45 }
46
47 [CustomAction]
48 public static ActionResult DeferredCA(Session session)
49 {
50 session.Log("Begin DeferredCA");
51
52 WriteNow(@"C:\Windows\Installer\DeferredCA.txt");
53
54 return ActionResult.Success;
55 }
56
57 private static void WriteNow(string path)
58 {
59 using (var file = File.Create(path))
60 {
61 var now = Encoding.UTF8.GetBytes(DateTime.Now.ToString("o"));
62 file.Write(now, 0, now.Length);
63 }
64 }
65 }
66 }