Example #1
0
        public void CanBuildBundleWithSlipstreamPatch()
        {
            var folder = TestData.Get(@"TestData\PatchSingle");

            using (var fs = new DisposableFileSystem())
            {
                var tempFolder = fs.GetFolder();

                var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0");
                var update1Pdb  = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1");
                var patchPdb    = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1");
                var bundleAPdb  = BuildBundle("BundleA.exe", Path.Combine(folder, "BundleA"), tempFolder);

                using (var wixOutput = WixOutput.Read(bundleAPdb))
                {
                    var manifestData = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName);
                    var doc          = new XmlDocument();
                    doc.LoadXml(manifestData);
                    var nsmgr = BundleExtractor.GetBurnNamespaceManager(doc, "w");
                    var slipstreamMspNodes = doc.SelectNodes("/w:BurnManifest/w:Chain/w:MsiPackage/w:SlipstreamMsp", nsmgr);
                    Assert.Equal(1, slipstreamMspNodes.Count);
                    Assert.Equal("<SlipstreamMsp Id='PatchA' />", slipstreamMspNodes[0].GetTestXml());
                }
            }
        }
Example #2
0
        public void Execute()
        {
            var trackedFiles = new List <ITrackedFile>();
            var group        = this.FilesWithEmbeddedFiles.GroupBy(e => e.Uri);

            foreach (var expectedEmbeddedFileByUri in group)
            {
                var baseUri = expectedEmbeddedFileByUri.Key;

                using (var wixout = WixOutput.Read(baseUri))
                {
                    var uniqueIds = new SortedSet <string>(StringComparer.OrdinalIgnoreCase);

                    foreach (var embeddedFile in expectedEmbeddedFileByUri)
                    {
                        if (uniqueIds.Add(embeddedFile.EmbeddedFileId))
                        {
                            wixout.ExtractEmbeddedFile(embeddedFile.EmbeddedFileId, embeddedFile.OutputPath);
                            trackedFiles.Add(this.BackendHelper.TrackFile(embeddedFile.OutputPath, TrackedFileType.Temporary));
                        }
                    }
                }
            }

            this.TrackedFiles = trackedFiles;
        }
Example #3
0
 /// <summary>
 /// Loads an output from a path on disk.
 /// </summary>
 /// <param name="path">Path to output file saved on disk.</param>
 /// <param name="tableDefinitions">Table definitions to use for creating strongly-typed rows.</param>
 /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
 /// <returns>Output object.</returns>
 public static WindowsInstallerData Load(string path, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck = false)
 {
     using (var wixOutput = WixOutput.Read(path))
     {
         return(WindowsInstallerData.Load(wixOutput, tableDefinitions, suppressVersionCheck));
     }
 }
Example #4
0
        public void CanLoadPdbGeneratedByBuildViaWixOutput()
        {
            var folder = TestData.Get(@"TestData\MultiFileCompressed");

            using (var fs = new DisposableFileSystem())
            {
                var intermediateFolder = fs.GetFolder();

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-d", "MediaTemplateCompressionLevel",
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(intermediateFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi")));
                Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\cab1.cab")));

                var pdbPath = Path.Combine(intermediateFolder, @"bin\test.wixpdb");
                Assert.True(File.Exists(pdbPath));

                var wixOutput = WixOutput.Read(pdbPath);
                var output    = WindowsInstallerData.Load(wixOutput, suppressVersionCheck: true);
                Assert.NotNull(output);
            }
        }
Example #5
0
        public void CanBuildBinaryWixlib()
        {
            var folder = TestData.Get(@"TestData\SingleFile");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-bindfiles",
                    "-o", Path.Combine(baseFolder, @"bin\test.wixlib"));

                result.AssertSuccess();

                using (var wixout = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixlib")))
                {
                    Assert.NotNull(wixout.GetDataStream("wix-ir.json"));

                    var text = wixout.GetData("wix-ir/test.txt");
                    Assert.Equal("This is test.txt.", text);
                }
            }
        }
Example #6
0
        public void CanBuildBinaryWixlibWithCollidingFilenames()
        {
            var folder = TestData.Get(@"TestData\SameFileFolders");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(
                    "build",
                    Path.Combine(folder, "TestComponents.wxs"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-bindfiles",
                    "-o", Path.Combine(baseFolder, @"bin\test.wixlib"));

                result.AssertSuccess();

                using (var wixout = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixlib")))
                {
                    Assert.NotNull(wixout.GetDataStream("wix-ir.json"));

                    var text = wixout.GetData("wix-ir/test.txt");
                    Assert.Equal(@"This is a\test.txt.", text);

                    var text2 = wixout.GetData("wix-ir/test.txt-1");
                    Assert.Equal(@"This is b\test.txt.", text2);

                    var text3 = wixout.GetData("wix-ir/test.txt-2");
                    Assert.Equal(@"This is c\test.txt.", text3);
                }
            }
        }
        public void VerifyPackageIsCached(string packageId)
        {
            using var wixOutput = WixOutput.Read(this.BundlePdb);
            var intermediate  = Intermediate.Load(wixOutput);
            var section       = intermediate.Sections.Single();
            var packageSymbol = section.Symbols.OfType <WixBundlePackageSymbol>().Single(p => p.Id.Id == packageId);
            var cachePath     = this.GetPackageCachePathForCacheId(packageSymbol.CacheId, packageSymbol.PerMachine == YesNoDefaultType.Yes);

            Assert.True(Directory.Exists(cachePath));
        }
Example #8
0
        private WindowsInstallerData GetWindowsInstallerData()
        {
            if (this.WiData == null)
            {
                using var wixOutput = WixOutput.Read(this.PackagePdb);
                this.WiData         = WindowsInstallerData.Load(wixOutput);
            }

            return(this.WiData);
        }
Example #9
0
        public void CanBuildBundleWithTag()
        {
            var testDataFolder = TestData.Get(@"TestData");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(testDataFolder, "ProductTag", "PackageWithTag.wxs"),
                    Path.Combine(testDataFolder, "ProductTag", "PackageComponents.wxs"),
                    "-loc", Path.Combine(testDataFolder, "ProductTag", "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(testDataFolder, "ProductTag"),
                    "-intermediateFolder", Path.Combine(intermediateFolder, "package"),
                    "-o", Path.Combine(baseFolder, "package", @"test.msi")
                });

                result.AssertSuccess();

                result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(testDataFolder, "BundleTag", "BundleWithTag.wxs"),
                    "-bindpath", Path.Combine(testDataFolder, "BundleTag"),
                    "-bindpath", Path.Combine(baseFolder, "package"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(baseFolder, @"bin\test.exe")
                });

                result.AssertSuccess();

                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.exe")));
                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));

                using (var ouput = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixpdb")))
                {
                    var badata = ouput.GetDataStream("wix-burndata.xml");
                    var doc    = XDocument.Load(badata);

                    var swidTag = doc.Root.Element(BurnManifestNamespace + "Registration").Element(BurnManifestNamespace + "SoftwareTag").Value;

                    var swidTagPath = Path.Combine(baseFolder, "test.swidtag");
                    File.WriteAllText(swidTagPath, swidTag);

                    var docTag  = XDocument.Load(swidTagPath);
                    var title   = docTag.Root.Attribute("name").Value;
                    var version = docTag.Root.Attribute("version").Value;
                    Assert.Equal("~TagTestBundle", title);
                    Assert.Equal("4.3.2.1", version);
                }
            }
        }
        public void CanBuildBundleWithTag()
        {
            var testDataFolder = TestData.Get(@"TestData");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var extPath            = Path.GetFullPath(new Uri(typeof(TagExtensionFactory).Assembly.CodeBase).LocalPath);

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(testDataFolder, "ProductTag", "PackageWithTag.wxs"),
                    Path.Combine(testDataFolder, "ProductTag", "PackageComponents.wxs"),
                    "-loc", Path.Combine(testDataFolder, "ProductTag", "Package.en-us.wxl"),
                    "-bindpath", Path.Combine(testDataFolder, "ProductTag"),
                    "-ext", extPath,
                    "-intermediateFolder", Path.Combine(intermediateFolder, "package"),
                    "-o", Path.Combine(baseFolder, "package", @"test.msi")
                });

                result.AssertSuccess();

                result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(testDataFolder, "BundleTag", "BundleWithTag.wxs"),
                    "-ext", extPath,
                    "-bindpath", Path.Combine(testDataFolder, "BundleTag"),
                    "-bindpath", Path.Combine(baseFolder, "package"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(baseFolder, @"bin\test.exe")
                });

                result.AssertSuccess();

                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.exe")));
                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));

                using var ouput = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixpdb"));

                var badata = ouput.GetDataStream("wix-badata.xml");
                var doc    = XDocument.Load(badata);

                var swidTag = doc.Root.Element("WixSoftwareTag").Value;
                var docTag  = XDocument.Parse(swidTag);

                var title   = docTag.Root.Element(SwidTagNamespace + "product_title").Value;
                var version = docTag.Root.Element(SwidTagNamespace + "product_version").Element(SwidTagNamespace + "name").Value;
                Assert.Equal("~TagTestBundle", title);
                Assert.Equal("4.3.2.1", version);
            }
        }
Example #11
0
        public void CanUpdateIntermediate()
        {
            var sln     = new SourceLineNumber("test.wxs", 1);
            var section = new IntermediateSection("test", SectionType.Product, 65001);

            section.Symbols.Add(new ComponentSymbol(sln, new Identifier(AccessModifier.Public, "TestComponent"))
            {
                ComponentId  = new Guid(1, 0, 0, new byte[8]).ToString("B"),
                DirectoryRef = "TestFolder",
                Location     = ComponentLocation.Either,
            });

            var intermediate = new Intermediate("TestIntermediate", IntermediateLevels.Compiled, new[] { section }, null);

            var path = Path.GetTempFileName();

            try
            {
                intermediate.Save(path);

                var uri    = new Uri(Path.GetFullPath(path));
                var stream = File.Open(path, FileMode.Open, FileAccess.ReadWrite);

                using (var wixout = WixOutput.Read(uri, stream))
                {
                    var loaded = Intermediate.Load(wixout);
                    var symbol = (ComponentSymbol)loaded.Sections.Single().Symbols.Single();

                    Assert.Equal("TestComponent", symbol.Id.Id);
                    Assert.Equal(AccessModifier.Public, symbol.Id.Access);

                    wixout.Reopen(writable: true);

                    section.Symbols.Add(new ComponentSymbol(sln, new Identifier(AccessModifier.Public, "NewComponent"))
                    {
                        ComponentId = new Guid(1, 0, 0, new byte[8]).ToString("B"),
                    });

                    intermediate.Save(wixout);
                    loaded = Intermediate.Load(wixout);

                    var newSymbol = loaded.Sections.Single().Symbols.Where(t => t.Id.Id == "NewComponent");
                    Assert.Single(newSymbol);
                }

                var loadedAfterDispose  = Intermediate.Load(path);
                var newSymbolStillThere = loadedAfterDispose.Sections.Single().Symbols.Where(t => t.Id.Id == "NewComponent");
                Assert.Single(newSymbolStillThere);
            }
            finally
            {
                File.Delete(path);
            }
        }
Example #12
0
        private WixBundleSymbol GetBundleSymbol()
        {
            if (this.BundleSymbol == null)
            {
                using var wixOutput = WixOutput.Read(this.BundlePdb);
                var intermediate = Intermediate.Load(wixOutput);
                var section      = intermediate.Sections.Single();
                this.BundleSymbol = section.Symbols.OfType <WixBundleSymbol>().Single();
            }

            return(this.BundleSymbol);
        }
Example #13
0
        public void RemovePackageFromCache(string packageId)
        {
            using var wixOutput = WixOutput.Read(this.BundlePdb);
            var intermediate  = Intermediate.Load(wixOutput);
            var section       = intermediate.Sections.Single();
            var packageSymbol = section.Symbols.OfType <WixBundlePackageSymbol>().Single(p => p.Id.Id == packageId);
            var cachePath     = this.GetPackageCachePathForCacheId(packageSymbol.CacheId, packageSymbol.PerMachine == YesNoDefaultType.Yes);

            if (Directory.Exists(cachePath))
            {
                Directory.Delete(cachePath, true);
            }
        }
Example #14
0
        public void CanBuildBundleWithLargePayload()
        {
            var folder = TestData.Get(@"TestData\LargePayload");

            // Overwrite the payload with a 2.5 GiB file. We do this dynamically to avoid committing such
            // a large file to source control.
            var        largeFile            = Path.Combine(folder, "data", "large_file.dat");
            const long TwoAndAHalfGigabytes = 2_684_354_560;

            using (var stream = File.Create(largeFile))
            {
                stream.Seek(TwoAndAHalfGigabytes - 1, SeekOrigin.Begin);
                stream.WriteByte(1);
            }

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var exePath            = Path.Combine(baseFolder, @"bin\test.exe");
                var pdbPath            = Path.Combine(baseFolder, @"bin\test.wixpdb");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Bundle.wxs"),
                    "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", exePath,
                });

                result.AssertSuccess();
                Assert.Empty(result.Messages.Where(m => m.Level == MessageLevel.Warning));

                Assert.True(File.Exists(exePath));
                Assert.True(File.Exists(pdbPath));
                Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\large_file.dat")));

                using (var wixOutput = WixOutput.Read(pdbPath))
                {
                    var intermediate = Intermediate.Load(wixOutput);
                    var section      = intermediate.Sections.Single();

                    var payloadSymbol = section.Symbols.OfType <WixBundlePayloadSymbol>().Where(x => x.Name == "large_file.dat").Single();
                    Assert.Equal(TwoAndAHalfGigabytes, payloadSymbol.FileSize);
                }
            }

            File.Delete(largeFile);
        }
        public PackageInstaller(WixTestContext testContext, string filename)
        {
            this.Package     = Path.Combine(testContext.TestDataFolder, $"{filename}.msi");
            this.PackagePdb  = Path.Combine(testContext.TestDataFolder, $"{filename}.wixpdb");
            this.TestContext = testContext;

            using var wixOutput = WixOutput.Read(this.PackagePdb);

            var intermediate    = Intermediate.Load(wixOutput);
            var section         = intermediate.Sections.Single();
            var platformSummary = section.Symbols.OfType <SummaryInformationSymbol>().Single(s => s.PropertyId == SummaryInformationType.PlatformAndLanguage);
            var platformString  = platformSummary.Value.Split(new char[] { ';' }, 2)[0];

            this.IsX64 = platformString != "Intel";

            this.WiData = WindowsInstallerData.Load(wixOutput);
        }
Example #16
0
        private static void VerifyPatchTargetCodes(string pdbPath, string[] expected)
        {
            using (var wixOutput = WixOutput.Read(pdbPath))
            {
                var manifestData = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName);
                var doc          = new XmlDocument();
                doc.LoadXml(manifestData);
                var nsmgr            = BundleExtractor.GetBurnNamespaceManager(doc, "w");
                var patchTargetCodes = doc.SelectNodes("/w:BurnManifest/w:PatchTargetCode", nsmgr);

                var actual = new List <string>();
                foreach (XmlNode patchTargetCodeNode in patchTargetCodes)
                {
                    actual.Add(patchTargetCodeNode.GetTestXml());
                }

                WixAssert.CompareLineByLine(expected, actual.ToArray());
            }
        }
Example #17
0
        public void IncludeSourceLineNumbersPreserved()
        {
            var folder = TestData.Get(@"TestData\IncludePath");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");

                var result = WixRunner.Execute(warningsAsErrors: false, new[]
                {
                    "build",
                    Path.Combine(folder, "Package.wxs"),
                    Path.Combine(folder, "PackageComponents.wxs"),
                    "-loc", Path.Combine(folder, "Package.en-us.wxl"),
                    "-includepath", Path.Combine(folder, "data"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", Path.Combine(baseFolder, @"bin\test.msi")
                });

                result.AssertSuccess();

                using (var output = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixpdb")))
                {
                    var intermediate = Intermediate.Load(output);
                    var component    = intermediate.Sections.Single().Symbols.OfType <ComponentSymbol>().Single();
                    Assert.Equal(3, component.SourceLineNumbers.LineNumber);
                    Assert.Equal(5, component.SourceLineNumbers.Parent.LineNumber);

                    var encoded = component.SourceLineNumbers.GetEncoded();
                    var decoded = SourceLineNumber.CreateFromEncoded(encoded);
                    Assert.Equal(3, decoded.LineNumber);
                    Assert.Equal(5, decoded.Parent.LineNumber);
                }
            }
        }
Example #18
0
        public void CanBuildSingleExeRemotePayloadBundle()
        {
            var folder = TestData.Get(@"TestData");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var exePath            = Path.Combine(baseFolder, @"bin\test.exe");
                var pdbPath            = Path.Combine(baseFolder, @"bin\test.wixpdb");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "SingleExeBundle", "SingleExeRemotePayload.wxs"),
                    Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
                    "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", exePath,
                });

                result.AssertSuccess();

                Assert.True(File.Exists(exePath));
                Assert.True(File.Exists(pdbPath));

                using (var wixOutput = WixOutput.Read(pdbPath))
                {
                    var intermediate = Intermediate.Load(wixOutput);
                    var section      = intermediate.Sections.Single();

                    var payloadSymbol = section.Symbols.OfType <WixBundlePayloadSymbol>().Where(x => x.Id.Id == "NetFx462Web").Single();
                    Assert.Equal(Int64.MaxValue, payloadSymbol.FileSize);
                }
            }
        }
Example #19
0
        public void CanBuildSimpleBundle()
        {
            var folder = TestData.Get(@"TestData\SimpleBundle");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var exePath            = Path.Combine(baseFolder, @"bin\test.exe");
                var pdbPath            = Path.Combine(baseFolder, @"bin\test.wixpdb");
                var baFolderPath       = Path.Combine(baseFolder, "ba");
                var extractFolderPath  = Path.Combine(baseFolder, "extract");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Bundle.wxs"),
                    "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", exePath,
                });

                result.AssertSuccess();
                Assert.Empty(result.Messages.Where(m => m.Level == MessageLevel.Warning));

                Assert.True(File.Exists(exePath));
                Assert.True(File.Exists(pdbPath));

                using (var wixOutput = WixOutput.Read(pdbPath))
                {
                    var intermediate = Intermediate.Load(wixOutput);
                    var section      = intermediate.Sections.Single();

                    var bundleSymbol = section.Symbols.OfType <WixBundleSymbol>().Single();
                    Assert.Equal("1.0.0.0", bundleSymbol.Version);

                    var previousVersion = bundleSymbol.Fields[(int)WixBundleSymbolFields.Version].PreviousValue;
                    Assert.Equal("!(bind.packageVersion.test.msi)", previousVersion.AsString());

                    var msiSymbol = section.Symbols.OfType <WixBundlePackageSymbol>().Single();
                    Assert.Equal("test.msi", msiSymbol.Id.Id);

                    var extractResult = BundleExtractor.ExtractBAContainer(null, exePath, baFolderPath, extractFolderPath);
                    extractResult.AssertSuccess();

                    var burnManifestData          = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName);
                    var extractedBurnManifestData = File.ReadAllText(Path.Combine(baFolderPath, "manifest.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBurnManifestData, burnManifestData);

                    var baManifestData          = wixOutput.GetData(BurnConstants.BootstrapperApplicationDataWixOutputStreamName);
                    var extractedBaManifestData = File.ReadAllText(Path.Combine(baFolderPath, "BootstrapperApplicationData.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBaManifestData, baManifestData);

                    var bextManifestData          = wixOutput.GetData(BurnConstants.BundleExtensionDataWixOutputStreamName);
                    var extractedBextManifestData = File.ReadAllText(Path.Combine(baFolderPath, "BundleExtensionData.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBextManifestData, bextManifestData);

                    var logElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Log");
                    var logElement  = (XmlNode)Assert.Single(logElements);
                    Assert.Equal("<Log PathVariable='WixBundleLog' Prefix='~TestBundle' Extension='log' />", logElement.GetTestXml());

                    var registrationElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Registration");
                    var registrationElement  = (XmlNode)Assert.Single(registrationElements);
                    Assert.Equal($"<Registration Id='{bundleSymbol.BundleId}' ExecutableName='test.exe' PerMachine='yes' Tag='' Version='1.0.0.0' ProviderKey='{bundleSymbol.BundleId}'>" +
                                 "<Arp Register='yes' DisplayName='~TestBundle' DisplayVersion='1.0.0.0' Publisher='Example Corporation' />" +
                                 "</Registration>", registrationElement.GetTestXml());

                    var msiPayloads = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Payload[@Id='test.msi']");
                    var msiPayload  = (XmlNode)Assert.Single(msiPayloads);
                    Assert.Equal("<Payload Id='test.msi' FilePath='test.msi' FileSize='*' Hash='*' Packaging='embedded' SourcePath='a0' Container='WixAttachedContainer' />",
                                 msiPayload.GetTestXml(new Dictionary <string, List <string> >()
                    {
                        { "Payload", new List <string> {
                              "FileSize", "Hash"
                          } }
                    }));
                }

                var manifestResource = new Resource(ResourceType.Manifest, "#1", 1033);
                manifestResource.Load(exePath);
                var actualManifestData = Encoding.UTF8.GetString(manifestResource.Data);
                Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                             "<assembly manifestVersion=\"1.0\" xmlns=\"urn:schemas-microsoft-com:asm.v1\">" +
                             "<assemblyIdentity name=\"test.exe\" version=\"1.0.0.0\" processorArchitecture=\"x86\" type=\"win32\" />" +
                             "<description>~TestBundle</description>" +
                             "<dependency><dependentAssembly><assemblyIdentity name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" type=\"win32\" /></dependentAssembly></dependency>" +
                             "<compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\"><application><supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" /><supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" /><supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" /><supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" /><supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" /></application></compatibility>" +
                             "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v3\"><security><requestedPrivileges><requestedExecutionLevel level=\"asInvoker\" uiAccess=\"false\" /></requestedPrivileges></security></trustInfo>" +
                             "<application xmlns=\"urn:schemas-microsoft-com:asm.v3\"><windowsSettings><dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true/pm</dpiAware><dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">PerMonitorV2, PerMonitor</dpiAwareness></windowsSettings></application>" +
                             "</assembly>", actualManifestData);
            }
        }
Example #20
0
        public void CanBuildSimpleBundle()
        {
            var folder = TestData.Get(@"TestData\SimpleBundle");

            using (var fs = new DisposableFileSystem())
            {
                var baseFolder         = fs.GetFolder();
                var intermediateFolder = Path.Combine(baseFolder, "obj");
                var exePath            = Path.Combine(baseFolder, @"bin\test.exe");
                var pdbPath            = Path.Combine(baseFolder, @"bin\test.wixpdb");
                var baFolderPath       = Path.Combine(baseFolder, "ba");
                var extractFolderPath  = Path.Combine(baseFolder, "extract");

                var result = WixRunner.Execute(new[]
                {
                    "build",
                    Path.Combine(folder, "Bundle.wxs"),
                    "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
                    "-bindpath", Path.Combine(folder, "data"),
                    "-intermediateFolder", intermediateFolder,
                    "-o", exePath,
                });

                result.AssertSuccess();
                Assert.Empty(result.Messages.Where(m => m.Level == MessageLevel.Warning));

                Assert.True(File.Exists(exePath));
                Assert.True(File.Exists(pdbPath));

                using (var wixOutput = WixOutput.Read(pdbPath))
                {
                    var intermediate = Intermediate.Load(wixOutput);
                    var section      = intermediate.Sections.Single();

                    var bundleSymbol = section.Symbols.OfType <WixBundleSymbol>().Single();
                    Assert.Equal("1.0.0.0", bundleSymbol.Version);

                    var previousVersion = bundleSymbol.Fields[(int)WixBundleSymbolFields.Version].PreviousValue;
                    Assert.Equal("!(bind.packageVersion.test.msi)", previousVersion.AsString());

                    var msiSymbol = section.Symbols.OfType <WixBundlePackageSymbol>().Single();
                    Assert.Equal("test.msi", msiSymbol.Id.Id);

                    var extractResult = BundleExtractor.ExtractBAContainer(null, exePath, baFolderPath, extractFolderPath);
                    extractResult.AssertSuccess();

                    var burnManifestData          = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName);
                    var extractedBurnManifestData = File.ReadAllText(Path.Combine(baFolderPath, "manifest.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBurnManifestData, burnManifestData);

                    var baManifestData          = wixOutput.GetData(BurnConstants.BootstrapperApplicationDataWixOutputStreamName);
                    var extractedBaManifestData = File.ReadAllText(Path.Combine(baFolderPath, "BootstrapperApplicationData.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBaManifestData, baManifestData);

                    var bextManifestData          = wixOutput.GetData(BurnConstants.BundleExtensionDataWixOutputStreamName);
                    var extractedBextManifestData = File.ReadAllText(Path.Combine(baFolderPath, "BundleExtensionData.xml"), Encoding.UTF8);
                    Assert.Equal(extractedBextManifestData, bextManifestData);

                    var logElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Log");
                    var logElement  = (XmlNode)Assert.Single(logElements);
                    Assert.Equal("<Log PathVariable='WixBundleLog' Prefix='~TestBundle' Extension='log' />", logElement.GetTestXml());

                    var registrationElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Registration");
                    var registrationElement  = (XmlNode)Assert.Single(registrationElements);
                    Assert.Equal($"<Registration Id='{bundleSymbol.BundleId}' ExecutableName='test.exe' PerMachine='yes' Tag='' Version='1.0.0.0' ProviderKey='{bundleSymbol.BundleId}'>" +
                                 "<Arp Register='yes' DisplayName='~TestBundle' DisplayVersion='1.0.0.0' Publisher='Example Corporation' />" +
                                 "</Registration>", registrationElement.GetTestXml());
                }
            }
        }