diff --git a/src/AddIns/Misc/PackageManagement/Cmdlets/Project/PackageManagement.Cmdlets.csproj b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/PackageManagement.Cmdlets.csproj
index 953386d35e..3d7650ffd2 100644
--- a/src/AddIns/Misc/PackageManagement/Cmdlets/Project/PackageManagement.Cmdlets.csproj
+++ b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/PackageManagement.Cmdlets.csproj
@@ -49,6 +49,7 @@
+
diff --git a/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/PackageManagementCmdlet.cs b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/PackageManagementCmdlet.cs
index f0f3154a60..0939bc2337 100644
--- a/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/PackageManagementCmdlet.cs
+++ b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/PackageManagementCmdlet.cs
@@ -90,7 +90,13 @@ namespace ICSharpCode.PackageManagement.Cmdlets
public void InvokeScript(string script)
{
- InvokeCommand.InvokeScript(script);
+ try {
+ InvokeCommand.InvokeScript(script);
+ } catch (RuntimeException ex) {
+ var errorMessage = new RuntimeExceptionErrorMessage(ex);
+ WriteWarning(errorMessage.ToString());
+ throw;
+ }
}
}
}
diff --git a/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/RuntimeExceptionErrorMessage.cs b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/RuntimeExceptionErrorMessage.cs
new file mode 100644
index 0000000000..13240f2ba5
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Cmdlets/Project/Src/RuntimeExceptionErrorMessage.cs
@@ -0,0 +1,46 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Management.Automation;
+using System.Text;
+
+namespace ICSharpCode.PackageManagement.Cmdlets
+{
+ public class RuntimeExceptionErrorMessage
+ {
+ StringBuilder message = new StringBuilder();
+
+ public RuntimeExceptionErrorMessage(RuntimeException ex)
+ {
+ CreateErrorMessage(ex);
+ }
+
+ void CreateErrorMessage(RuntimeException ex)
+ {
+ message.AppendLine(ex.Message);
+ AppendErrorRecord(ex.ErrorRecord);
+ }
+
+ void AppendErrorRecord(ErrorRecord errorRecord)
+ {
+ if (errorRecord != null) {
+ AppendInvocationInfo(errorRecord.InvocationInfo);
+ }
+ }
+
+ void AppendInvocationInfo(InvocationInfo invocationInfo)
+ {
+ if (invocationInfo != null) {
+ message.AppendLine(invocationInfo.PositionMessage);
+ message.AppendLine("Script Line: " + invocationInfo.ScriptLineNumber);
+ message.AppendLine("Script Name: " + invocationInfo.ScriptName);
+ }
+ }
+
+ public override string ToString()
+ {
+ return message.ToString();
+ }
+ }
+}