private static void OnFailure(Exception exception, string errorDetailsFile)
        {
            ImageBuilderExe.TraceSource.WriteWarning(
                ImageBuilderExe.TraceType,
                "ImageBuilderExe operation failed with the following exception: {0}",
                exception);

            if (!string.IsNullOrEmpty(errorDetailsFile))
            {
                try
                {
                    var errorDetails = new StringBuilder(exception.Message);
                    var inner        = exception.InnerException;
                    while (inner != null)
                    {
                        errorDetails.AppendFormat(" --> {0}: {1}", inner.GetType().Name, inner.Message);
                        inner = inner.InnerException;
                    }

                    ImageBuilderUtility.WriteStringToFile(
                        errorDetailsFile,
                        ImageBuilderExe.GetFabricErrorCodeOrEFail(exception) + "," + errorDetails.ToString(),
                        false,
                        Encoding.Unicode);
                }
                catch (Exception innerEx)
                {
                    ImageBuilderExe.TraceSource.WriteWarning(
                        ImageBuilderExe.TraceType,
                        "Failed to write error details: {0}",
                        innerEx.ToString());
                }
            }
        }
        private static Dictionary <string, string> ParseAppParameters(Dictionary <string, string> commandArgs)
        {
            Dictionary <string, string> applicationParameters = null;

            if (commandArgs.ContainsKey(StringConstants.AppParam))
            {
                string workingDirectory = null;
                if (commandArgs.ContainsKey(StringConstants.WorkingDir))
                {
                    workingDirectory = commandArgs[StringConstants.WorkingDir];
                }
                else
                {
                    workingDirectory = Directory.GetCurrentDirectory();
                }

                string appparametersFile = commandArgs.ContainsKey(StringConstants.AppParam) ?
                                           Path.Combine(workingDirectory, commandArgs[StringConstants.AppParam]) : null;
                ImageBuilderExe.ParseApplicationParametersFile(appparametersFile, out applicationParameters);
            }

            return(applicationParameters);
        }