public void BtsApplicationPropertiesTest() { var btsApplication = new BtsApplication("BtsSample"); btsApplication.Description = "BtsSample application"; btsApplication.Subject = "BizTalk build BtsSample"; btsApplication.Authors = "The Authors"; btsApplication.Manufacturer = "BtsSample Ltd"; btsApplication.ProductVersion = "2.5.2.1"; btsApplication.MsiVersion = BtsMsiLib.Model.MsiVersion.BT2020; var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource) { SourceLocation = @"c:\test1" }; var btsBindingsResource = new Resource(@"..\..\..\Data\BtsSample.BindingInfo.Dev.xml", ResourceType.Binding) { SourceLocation = @"c:\test1" }; var btsBindingsResource2 = new Resource(@"..\..\..\Data\BtsSample.BindingInfo.Test.xml", ResourceType.Binding) { SourceLocation = @"c:\test1" }; var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource, btsBindingsResource, btsBindingsResource2 }); using (var destinationFile = File.Create(@"..\..\..\Export\BtsApplicationPropertiesTest.msi")) { file.CopyTo(destinationFile); } }
public FileStream Write(BtsApplication btsApplication, Resource[] resources) { BtsApplicationValidator.Validate(btsApplication); ResourceValidator.Validate(resources); var cabFileWriter = new CabFileWriter(); var cabFolderPath = cabFileWriter.Write(resources); btsApplication.AddDefaultApplicationReference(); var adfFileWriter = new AdfFileWriter(); var adfFilePath = adfFileWriter.Write(btsApplication, resources); var msiFilePath = MsiFileWriter.Write(); var productCode = Guid.NewGuid(); var upgradeCode = Guid.NewGuid(); var properties = MsiFileWriter.GetProperties(btsApplication.Name, productCode, upgradeCode); using (var db = new Database(msiFilePath, DatabaseOpenMode.Direct)) { db.UpdateSummaryInfo(); db.UpdateUpgradeTable(upgradeCode); db.UpdateProperties(properties); db.UpdateFileContent(cabFolderPath, adfFilePath, resources.Length); db.MakeCustomModifications(productCode, btsApplication.Name); db.Commit(); } File.Delete(adfFilePath); Directory.Delete(cabFolderPath, true); return(File.OpenRead(msiFilePath)); }
public void MinimalisticBindingsTest() { var btsApplication = new BtsApplication("BtsSample"); btsApplication.MsiVersion = BtsMsiLib.Model.MsiVersion.BT2020; var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource) { SourceLocation = @"c:\test1" }; var btsBindingsResource = new Resource(@"..\..\..\Data\BtsSample.BindingInfo.Dev.xml", ResourceType.Binding) { SourceLocation = @"c:\test1" }; var btsBindingsResource2 = new Resource(@"..\..\..\Data\BtsSample.BindingInfo.Test.xml", ResourceType.Binding) { SourceLocation = @"c:\test1" }; var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource, btsBindingsResource, btsBindingsResource2 }); using (var destinationFile = File.Create(@"..\..\..\Export\MinimalisticBindingsTest.msi")) { file.CopyTo(destinationFile); } }
public void MinimalisticResourceTest() { var btsApplication = new BtsApplication("App1"); var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Utilities.dll", ResourceType.Resource); var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource }); using (var destinationFile = File.Create(@"..\..\..\Export\MinimalisticResourceTest.msi")) { file.CopyTo(destinationFile); } }
public void BtsApplicationReferenceTest() { var btsApplication = new BtsApplication("App1") { ReferencedApplications = new[] { "App2, App3" } }; var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource); var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource }); using (var destinationFile = File.Create(@"..\..\..\Export\BtsApplicationReferenceTest.msi")) { file.CopyTo(destinationFile); } }
public void DescriptionTest() { var btsApplication = new BtsApplication("App1") { Description = "Test desc" }; var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource); var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource }); using (var destinationFile = File.Create(@"..\..\..\Export\DescriptionTest.msi")) { file.CopyTo(destinationFile); } }
public void MinimalisticMixedResourceTest() { var btsApplication = new BtsApplication("App1"); var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource); var resource = new Resource(@"..\..\..\Data\BtsSample.Utilities.dll", ResourceType.Resource); var btsBindingsResource = new Resource(@"..\..\..\Data\BtsSample.BindingInfo.Dev.xml", ResourceType.Binding); var fileResource = new Resource(@"..\..\..\Data\BtsSample.FileToAdd1.txt", ResourceType.File); var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource, resource, btsBindingsResource, fileResource }); using (var destinationFile = File.Create(@"..\..\..\Export\MinimalisticMixedResourceTest.msi")) { file.CopyTo(destinationFile); } }
public void SourceLocationTest() { var btsApplication = new BtsApplication("App1"); var btsSchemaResource = new Resource(@"..\..\..\Data\BtsSample.Schemas.dll", ResourceType.BtsResource) { SourceLocation = @"c:\test1" }; var resource = new Resource(@"..\..\..\Data\BtsSample.Utilities.dll", ResourceType.Resource) { SourceLocation = @"c:\test2" }; var msiWriter = new MsiWriter(); var file = msiWriter.Write(btsApplication, new[] { btsSchemaResource, resource }); using (var destinationFile = File.Create(@"..\..\..\Export\SourceLocationTest.msi")) { file.CopyTo(destinationFile); } }
public string Write(BtsApplication btsApplication, Resource[] resources) { var propertyNodes = GetPropertyNodes(btsApplication.Name, btsApplication.Description, "1.0.0.0"); var resourceNodes = GetResourceNodes(resources); var resourceXElements = new List <XElement>(); foreach (var resourceNode in resourceNodes) { var resourceXElement = new XElement(AdfNs + "Resource", new XAttribute("Type", resourceNode.Type), new XAttribute("Luid", resourceNode.Luid)); var resourcePropertyXElements = resourceNode.Properties.Select(CreatePropertyXElement); var resourceFileXElements = resourceNode.Files.Select(CreateFileXElement); resourceXElement.Add(new XElement(AdfNs + "Properties", resourcePropertyXElements), new XElement(AdfNs + "Files", resourceFileXElements)); resourceXElements.Add(resourceXElement); } var content = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement(AdfNs + "ApplicationDefinition", new XAttribute(XNamespace.Xmlns + "xsd", XsdNs), new XAttribute(XNamespace.Xmlns + "xsi", XsiNs), new XElement(AdfNs + "Properties", propertyNodes.Select(CreatePropertyXElement)), new XElement(AdfNs + "Resources", resourceXElements), new XElement(AdfNs + "References", btsApplication.ReferencedApplications.Select(CreateReferenceXElement)))); var folderPath = string.Concat(Path.GetTempPath(), Guid.NewGuid()); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } var filePath = Path.Combine(folderPath, "adf.xml"); content.Save(filePath); return(filePath); }
/// <summary> /// MSBuild entry point for generating a MSI file based on a BizTalk Server project. /// </summary> public override bool Execute() { Log.LogMessage(MessageImportance.High, "Executing MsiTask version {0}", Assembly.GetExecutingAssembly().GetName().Version); if (!Directory.Exists(DestinationPath)) Directory.CreateDirectory((DestinationPath)); if (!string.IsNullOrEmpty(FileName) && Path.GetExtension(FileName) != ".msi") { Log.LogError("MSI file name has to end with file suffix '.MSI'"); return false; } if ((BtsAssemblies == null || !BtsAssemblies.Any()) && (Resources == null || !Resources.Any())) { throw new ArgumentException("No BizTalk Assemblies and no assembly resources found in build project input"); } // TODO: Add all checking of parameters to separate classes // TODO: Check all required in parameters and set possible defaults // TODO: Check that it's BT 2013 server from registry // TODO: Add better and cleaner error messages to msbuild output // TODO: Is it possible to check if assembly is signed or not? var resources = new List<Resource>(); if (BtsAssemblies != null && BtsAssemblies.Any()) resources.AddRange(BtsAssemblies.Select(r => new Resource(r.GetMetadata("Fullpath"), ResourceType.BtsResource))); if (Resources != null && Resources.Any()) resources.AddRange(Resources.Select(r => new Resource(r.GetMetadata("Fullpath"), ResourceType.Resource))); if (!string.IsNullOrEmpty(SourceLocation)) resources.ForEach(r => r.SourceLocation = SourceLocation); var references = new List<string>(); if (ReferenceApplications != null) references.AddRange(ReferenceApplications.Select(reference => reference.ItemSpec)); var btsApplication = new BtsApplication(ApplicationName) { Description = ApplicationDescription, ReferencedApplications = references.ToArray() }; var msiWriter = new BtsMsiLib.MsiWriter(); var msiFile = msiWriter.Write(btsApplication, resources.ToArray()); var destinationFilePath = Path.Combine(DestinationPath, FileHelper.GetMsiFileName(ApplicationName, FileName)); using (var destinationFile = File.Create(destinationFilePath)) { msiFile.CopyTo(destinationFile); } Log.LogMessage(MessageImportance.Normal, "MSI was successfully generated at {0}", destinationFilePath); return true; }
/// <summary> /// MSBuild entry point for generating a MSI file based on a BizTalk Server project. /// </summary> public override bool Execute() { Log.LogMessage(MessageImportance.High, "Executing MsiTask version {0}", Assembly.GetExecutingAssembly().GetName().Version); if (!Directory.Exists(DestinationPath)) { Directory.CreateDirectory((DestinationPath)); } if (!string.IsNullOrEmpty(FileName) && Path.GetExtension(FileName) != ".msi") { Log.LogError("MSI file name has to end with file suffix '.MSI'"); return(false); } if ((BtsAssemblies == null || !BtsAssemblies.Any()) && (Resources == null || !Resources.Any())) { throw new ArgumentException("No BizTalk Assemblies and no assembly resources found in build project input"); } // TODO: Add all checking of parameters to separate classes // TODO: Check all required in parameters and set possible defaults // TODO: Check that it's BT 2013 server from registry // TODO: Add better and cleaner error messages to msbuild output // TODO: Is it possible to check if assembly is signed or not? var resources = new List <Resource>(); if (BtsAssemblies != null && BtsAssemblies.Any()) { resources.AddRange(BtsAssemblies.Select(r => new Resource(r.GetMetadata("Fullpath"), ResourceType.BtsResource))); } if (Resources != null && Resources.Any()) { resources.AddRange(Resources.Select(r => new Resource(r.GetMetadata("Fullpath"), ResourceType.Resource))); } if (!string.IsNullOrEmpty(SourceLocation)) { resources.ForEach(r => r.SourceLocation = SourceLocation); } var references = new List <string>(); if (ReferenceApplications != null) { references.AddRange(ReferenceApplications.Select(reference => reference.ItemSpec)); } var btsApplication = new BtsApplication(ApplicationName) { Description = ApplicationDescription, ReferencedApplications = references.ToArray() }; var msiWriter = new BtsMsiLib.MsiWriter(); var msiFile = msiWriter.Write(btsApplication, resources.ToArray()); var destinationFilePath = Path.Combine(DestinationPath, FileHelper.GetMsiFileName(ApplicationName, FileName)); using (var destinationFile = File.Create(destinationFilePath)) { msiFile.CopyTo(destinationFile); } Log.LogMessage(MessageImportance.Normal, "MSI was successfully generated at {0}", destinationFilePath); return(true); }