public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            try
            {
                BizTalkAssemblyResolver.Register(msg => Context.LogMessage(msg));
                ApplyContextArguments();
                if (Context.Parameters.ContainsKey("BindingFilePath"))
                {
                    var bindingFilePath = Context.Parameters["BindingFilePath"];
                    GenerateBindingFile(bindingFilePath);
                }
                if (Context.Parameters.ContainsKey("SetupFileAdapterPaths"))
                {
                    var users = Context.Parameters["Users"].IfNotNullOrEmpty(u => u.Split(';', ','));
                    SetupFileAdapterPaths(users);
                }
                if (Context.Parameters.ContainsKey("InitializeServices"))
                {
                    InitializeServices();
                }
            }
            finally
            {
                BizTalkAssemblyResolver.Unregister();
            }
        }
        public override bool Execute()
        {
            try
            {
                BizTalkAssemblyResolver.Register(msg => Log.LogMessage(msg));
                var assemblyPaths = PipelineDefinitionAssemblies
                                    .Select(ra => ra.GetMetadata("Identity"))
                                    .ToArray();
                BizTalkAssemblyResolver.RegisterProbingPaths(assemblyPaths.Select(Path.GetDirectoryName).ToArray());

                // TODO refactor this in task ResolveReferencedBizTalkPipelineAssemblies
                var pipelineTypes = assemblyPaths
                                    .Select(Assembly.LoadFrom)
                                    // make sure all assemblies are loaded before proceeding with reflection
                                    .ToArray()
                                    // discard Be.Stateless.BizTalk.Dsl assembly
                                    .Where(a => a != typeof(ReceivePipeline).Assembly)
                                    .SelectMany(a => a.GetTypes())
                                    .Where(t => !t.IsAbstract && !t.IsGenericTypeDefinition)
                                    .Where(t => typeof(ReceivePipeline).IsAssignableFrom(t) || typeof(SendPipeline).IsAssignableFrom(t));

                // TODO delete all previously generated files

                var outputs = new List <ITaskItem>();
                foreach (var pipelineType in pipelineTypes)
                {
                    var path = ComputeOutputPath(pipelineType);
                    Log.LogMessage(MessageImportance.High, "Generating pipeline '{0}'.", pipelineType.FullName);
                    // ReSharper disable once AssignNullToNotNullAttribute
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    var pipelineSerializerFactory = (IPipelineSerializerFactory)Activator.CreateInstance(pipelineType);
                    pipelineSerializerFactory.GetPipelineDesignerDocumentSerializer().Save(path);
                    Log.LogMessage(MessageImportance.High, "Adding pipeline to item group {0}", path);
                    var taskItem = new TaskItem(path);
                    taskItem.SetMetadata("TypeName", pipelineType.Name);
                    taskItem.SetMetadata("Namespace", pipelineType.Namespace);
                    outputs.Add(taskItem);
                }
                PipelineFiles = outputs.ToArray();
                return(true);
            }
            catch (Exception exception)
            {
                Log.LogErrorFromException(exception, true, true, null);
                return(false);
            }
            finally
            {
                BizTalkAssemblyResolver.Unregister();
            }
        }
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);

            try
            {
                BizTalkAssemblyResolver.Register(msg => Context.LogMessage(msg));
                ApplyContextArguments();
                if (Context.Parameters.ContainsKey("TeardownFileAdapterPaths"))
                {
                    var recurse = Context.Parameters.ContainsKey("Recurse");
                    TeardownFileAdapterPaths(recurse);
                }
            }
            finally
            {
                BizTalkAssemblyResolver.Unregister();
            }
        }