From 760fb810ba5ecc3c6ce752a9bfa3755f7b7c0f6a Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 25 Feb 2021 09:58:20 -0800 Subject: Absorb Tag.wixext into Core as SoftwareTag element Resolves wixtoolset/issues#5949 --- .../SoftwareTagFixture.cs | 100 +++++++++++++++++++++ .../TestData/BundleTag/BundleWithTag.wxs | 15 ++++ .../TestData/BundleTag/fakeba.dll | 1 + .../TestData/ProductTag/Package.en-us.wxl | 11 +++ .../TestData/ProductTag/PackageComponents.wxs | 10 +++ .../TestData/ProductTag/PackageWithTag.wxs | 20 +++++ .../TestData/ProductTag/example.txt | 1 + 7 files changed, 158 insertions(+) create mode 100644 src/test/WixToolsetTest.CoreIntegration/SoftwareTagFixture.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/BundleWithTag.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/fakeba.dll create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageWithTag.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/example.txt (limited to 'src/test/WixToolsetTest.CoreIntegration') diff --git a/src/test/WixToolsetTest.CoreIntegration/SoftwareTagFixture.cs b/src/test/WixToolsetTest.CoreIntegration/SoftwareTagFixture.cs new file mode 100644 index 00000000..15276b18 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/SoftwareTagFixture.cs @@ -0,0 +1,100 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.CoreIntegration +{ + using System.IO; + using System.Linq; + using System.Xml.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Data; + using Xunit; + + public class SoftwareTagFixture + { + private static readonly XNamespace BurnManifestNamespace = "http://wixtoolset.org/schemas/v4/2008/Burn"; + private static readonly XNamespace SwidTagNamespace = "http://standards.iso.org/iso/19770/-2/2009/schema.xsd"; + + [Fact] + public void CanBuildPackageWithTag() + { + var folder = TestData.Get(@"TestData\ProductTag"); + var build = new Builder(folder, null, new[] { folder }); + + var results = build.BuildAndQuery(Build, "File", "SoftwareIdentificationTag"); + + var replacePackageCodeStart = results[2].IndexOf("\tmsi:package/") + "\tmsi:package/".Length; + var replacePackageCodeEnd = results[2].IndexOf("\t", replacePackageCodeStart); + results[2] = results[2].Substring(0, replacePackageCodeStart) + "???" + results[2].Substring(replacePackageCodeEnd); + WixAssert.CompareLineByLine(new[] + { + "File:filF5_pLhBuF5b4N9XEo52g_hUM5Lo\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\texample.txt\t20\t\t\t512\t1", + "File:tagEYRYWwOt95punO7qPPAQ9p1GBpY\ttagEYRYWwOt95punO7qPPAQ9p1GBpY\trdcfonyt.swi|~TagTestPackage.swidtag\t449\t\t\t1\t2", + "SoftwareIdentificationTag:tagEYRYWwOt95punO7qPPAQ9p1GBpY\twixtoolset.org\tmsi:package/???\tmsi:upgrade/047730A5-30FE-4A62-A520-DA9381B8226A\t" + }, results.ToArray()); + } + + [Fact] + 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); + } + } + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/BundleWithTag.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/BundleWithTag.wxs new file mode 100644 index 00000000..f44fb7bc --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/BundleWithTag.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/fakeba.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/fakeba.dll new file mode 100644 index 00000000..64061ea0 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleTag/fakeba.dll @@ -0,0 +1 @@ +This is fakeba.dll. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageComponents.wxs new file mode 100644 index 00000000..37a2c462 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageComponents.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageWithTag.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageWithTag.wxs new file mode 100644 index 00000000..17543c1a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/PackageWithTag.wxs @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/example.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductTag/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file -- cgit v1.2.3-55-g6feb