private void ExportToMsi()
        {
            if (string.IsNullOrEmpty(this.Application))
            {
                this.Log.LogError("Application is required");
                return;
            }

            if (this.MsiPath == null)
            {
                this.Log.LogError("Destination is required");
                return;
            }

            if (this.Resources == null)
            {
                this.Resources = new ITaskItem[] { };
            }

            if (!this.CheckExists(this.Application))
            {
                this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "Application does not exist: {0}", this.Application));
                return;
            }

            this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Exporting Application {0} to {1}", this.Application, this.MsiPath));
            using (Group group = new Group())
            {
                group.DBName   = this.Database;
                group.DBServer = this.DatabaseServer;

                Microsoft.BizTalk.ApplicationDeployment.ApplicationCollection apps = group.Applications;
                apps.UiLevel = 2;

                Microsoft.BizTalk.ApplicationDeployment.Application appl = apps[this.Application];
                List <Resource> exportedResources = new List <Resource>();

                foreach (Resource resource in appl.ResourceCollection.Cast <Resource>().Where(resource => !resource.Properties.ContainsKey("IsSystem") || !((bool)resource.Properties["IsSystem"])))
                {
                    if (this.IncludeGlobalPartyBinding && resource.Luid.Equals("Application/" + this.Application, StringComparison.OrdinalIgnoreCase))
                    {
                        resource.Properties["IncludeGlobalPartyBinding"] = this.IncludeGlobalPartyBinding;
                    }

                    // only export specified resources
                    if (this.Resources.Length != 0 && !this.Resources.Any(item => item.ItemSpec == resource.Luid))
                    {
                        continue;
                    }

                    this.LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "Exporting Resource {0}", resource.Luid));
                    exportedResources.Add(resource);
                }

                appl.Export(this.MsiPath.ItemSpec, exportedResources);
            }
        }
Beispiel #2
0
 public string GetApplicationVersion(string application)
 {
     try
     {
         BtsCatalogExplorer btsExplorer = (BtsCatalogExplorer)grp.CatalogExplorer;
         Microsoft.BizTalk.ApplicationDeployment.ApplicationCollection apps = grp.Applications;
         Microsoft.BizTalk.ApplicationDeployment.Application           app  = apps[application];
         if (null != app)
         {
             return(app.Description);
         }
     }
     catch (Exception exception)
     {
         throw new Exception(string.Format("BizTalkGroup.GetApplicationVersion failed: {0}", exception.Message), exception);
     }
     finally
     {
     }
     return("0.0.0.0");
 }
        private void DeleteApplication(ITaskItem application)
        {
            if (!this.CheckExists(application.ItemSpec))
            {
                return;
            }

            using (Group group = new Group())
            {
                group.DBName   = this.Database;
                group.DBServer = this.DatabaseServer;

                Microsoft.BizTalk.ApplicationDeployment.ApplicationCollection apps = group.Applications;
                apps.UiLevel = 2;

                Microsoft.BizTalk.ApplicationDeployment.Application deadapp = apps[application.ItemSpec];
                this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Application: {0} - {1}", application.ItemSpec, this.TaskAction));
                apps.Remove(deadapp);
            }

            this.explorer.SaveChanges();
        }