diff --git a/PowerShellActions/CustomAction.cs b/PowerShellActions/CustomAction.cs
index 6df22c7..0794d13 100644
--- a/PowerShellActions/CustomAction.cs
+++ b/PowerShellActions/CustomAction.cs
@@ -207,7 +207,7 @@ private static ActionResult FilesImmediate(Session session, int elevated, string
try
{
XDocument doc;
- using (View view = db.OpenView(string.Format("SELECT `Id`, `File`, `Arguments` FROM `{0}` WHERE `Elevated` = {1}", tableName, elevated)))
+ using (View view = db.OpenView(string.Format("SELECT `Id`, `File`, `Arguments`, `IgnoreErrors` FROM `{0}` WHERE `Elevated` = {1}", tableName, elevated)))
{
view.Execute();
@@ -216,11 +216,12 @@ private static ActionResult FilesImmediate(Session session, int elevated, string
foreach (Record row in view)
{
var args = session.Format(row["Arguments"].ToString());
+ var IgnoreErrors = session.Format(row["IgnoreErrors"].ToString());
session.Log("args '{0}'", args);
doc.Root.Add(new XElement("d", new XAttribute("Id", row["Id"]),
- new XAttribute("file", session.Format(row["File"].ToString())), new XAttribute("args", args)));
+ new XAttribute("file", session.Format(row["File"].ToString())), new XAttribute("args", args), new XAttribute("IgnoreErrors", IgnoreErrors)));
}
}
@@ -310,15 +311,40 @@ private static ActionResult FilesDeferred(Session session, string deferredProper
string file = row.Attribute("file").Value;
string arguments = row.Attribute("args").Value;
+ string IgnoreErrors = row.Attribute("IgnoreErrors").Value;
using (var task = new PowerShellTask(file, arguments, session))
{
- bool result = task.Execute();
- session.Log("PowerShell non-terminating errors: {0}", !result);
- if (!result)
+ try
{
- session.Log("Returning Failure");
- return ActionResult.Failure;
+ bool result = task.Execute();
+ session.Log("PowerShell non-terminating errors: {0}", !result);
+ if (!result)
+ {
+ if (!IgnoreErrors.Equals("0"))
+ {
+ session.Log("Ignoring failure due to 'IgnoreErrors' marking");
+ }
+ else
+ {
+ session.Log("Returning Failure");
+ return ActionResult.Failure;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ if (!IgnoreErrors.Equals("0"))
+ {
+ session.Log("Ignoring PowerShell error due to 'IgnoreErrors' marking");
+ session.Log(ex.ToString());
+ }
+ else
+ {
+ session.Log("PowerShell terminating error, returning Failure");
+ session.Log(ex.ToString());
+ return ActionResult.Failure;
+ }
}
}
}
diff --git a/PowerShellWixExtension/PowerShellCompilerExtension.cs b/PowerShellWixExtension/PowerShellCompilerExtension.cs
index 5c2c136..800ffe5 100644
--- a/PowerShellWixExtension/PowerShellCompilerExtension.cs
+++ b/PowerShellWixExtension/PowerShellCompilerExtension.cs
@@ -60,6 +60,7 @@ private void ParseFileElement(XmlNode node)
string file = null;
string arguments = null;
var elevated = YesNoType.No;
+ YesNoType ignoreErrors = YesNoType.No;
foreach (XmlAttribute attribute in node.Attributes)
{
@@ -80,6 +81,9 @@ private void ParseFileElement(XmlNode node)
case "Elevated":
elevated = Core.GetAttributeYesNoValue(sourceLineNumber, attribute);
break;
+ case "IgnoreErrors":
+ ignoreErrors = Core.GetAttributeYesNoValue(sourceLineNumber, attribute);
+ break;
default:
Core.UnexpectedAttribute(sourceLineNumber, attribute);
break;
@@ -111,6 +115,7 @@ private void ParseFileElement(XmlNode node)
superElementRow[1] = file;
superElementRow[2] = arguments;
superElementRow[3] = elevated == YesNoType.Yes ? 1 : 0;
+ superElementRow[4] = (ignoreErrors == YesNoType.Yes) ? 1 : 0;
}
Core.CreateWixSimpleReferenceRow(sourceLineNumber, "CustomAction", "PowerShellFilesImmediate");
diff --git a/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd b/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd
index e868044..b1b7bd5 100644
--- a/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd
+++ b/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd
@@ -88,6 +88,12 @@
+
+
+ Set to true to ignore PowerShell errors
+
+
+
diff --git a/PowerShellWixExtension/TableDefinitions.xml b/PowerShellWixExtension/TableDefinitions.xml
index 060e0ad..fa733e5 100644
--- a/PowerShellWixExtension/TableDefinitions.xml
+++ b/PowerShellWixExtension/TableDefinitions.xml
@@ -61,6 +61,16 @@
nullable="no"
description="Run as elevated" />
+
+
\ No newline at end of file