-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.cs
62 lines (49 loc) · 1.68 KB
/
setup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//css_dir ..\..\;
//css_ref System.Core.dll;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
using System;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
#if Wix4
using WixToolset.Dtf.WindowsInstaller;
#else
using Microsoft.Deployment.WindowsInstaller;
#endif
using WixSharp;
using WixSharp.CommonTasks;
public class Script
{
static public void Main()
{
var project = new ManagedProject("CustomActionTest",
new Dir(@"%ProgramFiles%\My Company\My Product",
new File("setup.cs")),
new ManagedAction(CustomActions.MyAction, Return.check, When.Before, Step.LaunchConditions, Condition.NOT_Installed),
new Error("9000", "Hello World! (CLR: v[2]) Embedded Managed CA ([3])"));
//project.Platform = Platform.x64;
project.PreserveTempFiles = true;
// project.OutDir = "bin";
project.BuildMsi();
}
}
public class CustomActions
{
[CustomAction]
public static ActionResult MyAction(Session session)
{
Record record = new Record(3);
record[1] = "9000";
record[2] = Environment.Version;
record[3] = Is64BitProcess ? "x64" : "x86";
session.Message(InstallMessage.User | (InstallMessage)MessageButtons.OK | (InstallMessage)MessageIcon.Information, record);
//MessageBox.Show("Hello World! (CLR: v" + Environment.Version + ")", "Embedded Managed CA (" + (Is64BitProcess ? "x64" : "x86") + ")");
session.Log("Begin MyAction Hello World");
return ActionResult.Success;
}
public static bool Is64BitProcess
{
get { return IntPtr.Size == 8; }
}
}