From 3f583916719eeef598d10a5d4e14ef14f008243b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 11 May 2021 07:36:37 -0700 Subject: Merge Dtf --- .../Dtf/Documents/Guide/Content/samplecas.htm | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/samples/Dtf/Documents/Guide/Content/samplecas.htm (limited to 'src/samples/Dtf/Documents/Guide/Content/samplecas.htm') diff --git a/src/samples/Dtf/Documents/Guide/Content/samplecas.htm b/src/samples/Dtf/Documents/Guide/Content/samplecas.htm new file mode 100644 index 00000000..4dfed6f0 --- /dev/null +++ b/src/samples/Dtf/Documents/Guide/Content/samplecas.htm @@ -0,0 +1,84 @@ + + + Sample C# Custom Action + + + + + + +
+ Deployment Tools Foundation
+ Sample C# Custom Action
+
+ + Development Guide > + Managed CAs > + Writing CAs > + C# Sample + +
+
+
+ +
+ +

MSI custom actions are MUCH easier to write in C# than + in C++!

    [CustomAction]
+    public static ActionResult SampleCustomAction1(Session session)
+    {
+        session.Log("Hello from SampleCA1");
+        
+        string testProp = session["SampleCATest"];
+        string testProp2;
+        testProp2 = (string) session.Database.ExecuteScalar(
+            "SELECT `Value` FROM `Property` WHERE `Property` = 'SampleCATest'");
+        
+        if(testProp == testProp2)
+        {
+            session.Log("Simple property test passed.");
+            return ActionResult.Success;
+        }
+        else
+            return ActionResult.Failure;
+    }
+            
+

A sample CA project with two CAs is included in the + Samples\ManagedCA directory.  Running the CustomActionTest project will package the CA and insert + it into a test MSI. The MSI will invoke the custom actions, but it will not install anything + since the second sample CA returns ActionResult.UserExit. +

+ +


+

See also:

+ +


+ +
+ + +
+ + + -- cgit v1.2.3-55-g6feb