aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-08-26 17:47:46 -0700
committerRob Mensching <rob@firegiant.com>2022-08-26 22:09:49 -0700
commit3e0e54aff605da9c5ec6c02f7e83d5e816c857a2 (patch)
treee09e2d4e16620e4587af8e7a35f23a3c1db803a7
parent7b59be82400f3c4d6e4f294940118e85b77f5a92 (diff)
downloadwix-3e0e54aff605da9c5ec6c02f7e83d5e816c857a2.tar.gz
wix-3e0e54aff605da9c5ec6c02f7e83d5e816c857a2.tar.bz2
wix-3e0e54aff605da9c5ec6c02f7e83d5e816c857a2.zip
Update old test code to latest SWID tag spec
Fixes 6675
-rw-r--r--src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj3
-rw-r--r--src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj3
-rw-r--r--src/test/burn/TestData/Templates/Bundle.wxs2
-rw-r--r--src/test/burn/TestData/Templates/Package.wxs8
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs13
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs59
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt1
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs28
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs16
9 files changed, 121 insertions, 12 deletions
diff --git a/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj b/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj
index 9b91b3f4..5eeaff59 100644
--- a/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj
+++ b/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj
@@ -5,6 +5,9 @@
5 <IncludeSoftwareTag>true</IncludeSoftwareTag> 5 <IncludeSoftwareTag>true</IncludeSoftwareTag>
6 <UpgradeCode>{AA083618-6280-44B8-9899-57BCC57906A5}</UpgradeCode> 6 <UpgradeCode>{AA083618-6280-44B8-9899-57BCC57906A5}</UpgradeCode>
7 </PropertyGroup> 7 </PropertyGroup>
8 <PropertyGroup>
9 <Version>1.0.1.0</Version>
10 </PropertyGroup>
8 <ItemGroup> 11 <ItemGroup>
9 <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" /> 12 <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
10 </ItemGroup> 13 </ItemGroup>
diff --git a/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj b/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj
index da9acb5e..6163691a 100644
--- a/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj
+++ b/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj
@@ -1,8 +1,7 @@
1<!-- 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. --> 1<!-- 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. -->
2<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 5 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 6 </PropertyGroup>
8 <ItemGroup> 7 <ItemGroup>
diff --git a/src/test/burn/TestData/Templates/Bundle.wxs b/src/test/burn/TestData/Templates/Bundle.wxs
index c55f67a7..43974524 100644
--- a/src/test/burn/TestData/Templates/Bundle.wxs
+++ b/src/test/burn/TestData/Templates/Bundle.wxs
@@ -14,7 +14,7 @@
14 <Variable Name="TestGroupName" Value="$(var.TestGroupName)" /> 14 <Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
15 15
16 <?ifdef SoftwareTag?> 16 <?ifdef SoftwareTag?>
17 <SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]regid.1995-08.com.example" /> 17 <SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]TestingSwidTags" />
18 <?endif?> 18 <?endif?>
19 19
20 <?ifndef BA?> 20 <?ifndef BA?>
diff --git a/src/test/burn/TestData/Templates/Package.wxs b/src/test/burn/TestData/Templates/Package.wxs
index c7597131..a1189fd9 100644
--- a/src/test/burn/TestData/Templates/Package.wxs
+++ b/src/test/burn/TestData/Templates/Package.wxs
@@ -20,7 +20,7 @@
20 <?endif?> 20 <?endif?>
21 21
22 <?ifdef SoftwareTag?> 22 <?ifdef SoftwareTag?>
23 <SoftwareTag Regid="regid.1995-08.com.example" InstallDirectory="CommonAppDataFolder" /> 23 <SoftwareTag Regid="regid.1995-08.com.example" InstallDirectory="SwidTagBaseFolder" />
24 <?endif?> 24 <?endif?>
25 25
26 <PropertyRef Id="TestVersion" /> 26 <PropertyRef Id="TestVersion" />
@@ -35,6 +35,12 @@
35 </Package> 35 </Package>
36 36
37 <Fragment> 37 <Fragment>
38 <?ifdef SoftwareTag?>
39 <StandardDirectory Id="CommonAppDataFolder">
40 <Directory Id="SwidTagBaseFolder" Name="TestingSwidTags" />
41 </StandardDirectory>
42 <?endif?>
43
38 <StandardDirectory Id="ProgramFiles6432Folder"> 44 <StandardDirectory Id="ProgramFiles6432Folder">
39 <Directory Id="WixDir" Name="~Test WiX"> 45 <Directory Id="WixDir" Name="~Test WiX">
40 <Directory Id="TestDir" Name="$(var.TestGroupName)"> 46 <Directory Id="TestDir" Name="$(var.TestGroupName)">
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs
index b63be5f5..b0cdea16 100644
--- a/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs
+++ b/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs
@@ -56,7 +56,7 @@ namespace WixToolsetTest.BurnE2E
56 packageAv1.VerifyTestRegistryRootDeleted(); 56 packageAv1.VerifyTestRegistryRootDeleted();
57 } 57 }
58 58
59 [RuntimeFact(Skip = "https://github.com/wixtoolset/issues/issues/6675")] 59 [RuntimeFact]
60 public void CanPatchSwidTag() 60 public void CanPatchSwidTag()
61 { 61 {
62 var originalVersion = "1.0.0.0"; 62 var originalVersion = "1.0.0.0";
@@ -116,8 +116,7 @@ namespace WixToolsetTest.BurnE2E
116 116
117 private static void VerifySwidTagVersion(string tagName, string expectedVersion) 117 private static void VerifySwidTagVersion(string tagName, string expectedVersion)
118 { 118 {
119 var regidFolder = Environment.ExpandEnvironmentVariables(@"%ProgramData%\regid.1995-08.com.example"); 119 var tagPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "TestingSwidTags", "swidtag", tagName + ".swidtag");
120 var tagPath = Path.Combine(regidFolder, "regid.1995-08.com.example " + tagName + ".swidtag");
121 string version = null; 120 string version = null;
122 121
123 if (File.Exists(tagPath)) 122 if (File.Exists(tagPath))
@@ -126,11 +125,15 @@ namespace WixToolsetTest.BurnE2E
126 doc.Load(tagPath); 125 doc.Load(tagPath);
127 126
128 var ns = new XmlNamespaceManager(doc.NameTable); 127 var ns = new XmlNamespaceManager(doc.NameTable);
129 ns.AddNamespace("s", "http://standards.iso.org/iso/19770/-2/2009/schema.xsd"); 128 ns.AddNamespace("s", "http://standards.iso.org/iso/19770/-2/2015/schema.xsd");
130 129
131 var versionNode = doc.SelectSingleNode("/s:software_identification_tag/s:product_version/s:name", ns); 130 var versionNode = doc.SelectSingleNode("/s:SoftwareIdentity/@version", ns);
132 version = versionNode?.InnerText ?? String.Empty; 131 version = versionNode?.InnerText ?? String.Empty;
133 } 132 }
133 else
134 {
135 Assert.True(expectedVersion == null, $"Did not find SWID tag with expected version {expectedVersion} at: {tagPath}");
136 }
134 137
135 Assert.Equal(expectedVersion, version); 138 Assert.Equal(expectedVersion, version);
136 } 139 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
index a26472fa..5bf770ac 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
@@ -9,6 +9,7 @@ namespace WixToolsetTest.CoreIntegration
9 using System.Linq; 9 using System.Linq;
10 using System.Runtime.InteropServices; 10 using System.Runtime.InteropServices;
11 using System.Text; 11 using System.Text;
12 using System.Text.RegularExpressions;
12 using System.Xml; 13 using System.Xml;
13 using System.Xml.Linq; 14 using System.Xml.Linq;
14 using Example.Extension; 15 using Example.Extension;
@@ -87,6 +88,50 @@ namespace WixToolsetTest.CoreIntegration
87 } 88 }
88 89
89 [Fact] 90 [Fact]
91 public void CanBuildSimplePatchWithSoftwareTag()
92 {
93 var folder = TestData.Get(@"TestData", "PatchWithSoftwareTag");
94
95 using (var fs = new DisposableFileSystem())
96 {
97 var baseFolder = fs.GetFolder();
98 var tempFolderBaseline = Path.Combine(baseFolder, "baseline");
99 var tempFolderUpdate = Path.Combine(baseFolder, "update");
100 var tempFolderPatch = Path.Combine(baseFolder, "patch");
101
102 var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolderBaseline, "1.0.0", "1.0.0", "1.0.0");
103 var update1Pdb = BuildMsi("Update.msi", folder, tempFolderUpdate, "1.0.1", "1.0.1", "1.0.1");
104 var patchPdb = BuildMsp("Patch1.msp", folder, tempFolderPatch, "1.0.1", bindpaths: new[] { Path.GetDirectoryName(baselinePdb), Path.GetDirectoryName(update1Pdb) });
105 var patchPath = Path.ChangeExtension(patchPdb, ".msp");
106
107 var doc = GetExtractPatchXml(patchPath);
108 WixAssert.StringEqual("{7D326855-E790-4A94-8611-5351F8321FCA}", doc.Root.Element(PatchNamespace + "TargetProductCode").Value);
109
110 var names = Query.GetSubStorageNames(patchPath);
111 WixAssert.CompareLineByLine(new[] { "#RTM.1", "RTM.1" }, names);
112
113 var cab = Path.Combine(baseFolder, "foo.cab");
114 Query.ExtractStream(patchPath, "foo.cab", cab);
115 Assert.True(File.Exists(cab));
116
117 var files = Query.GetCabinetFiles(cab);
118 var file = files.Single();
119 WixAssert.StringEqual("tag1jwIT_7lT286E4Dyji95s65UuO4", file.Name);
120
121 var contents = file.OpenText().ReadToEnd();
122 contents = Regex.Replace(contents, @"msi\:package/[A-Z0-9\-]+", "msi:package/G-U-I-D");
123 WixAssert.StringEqual(String.Join(Environment.NewLine, new[]
124 {
125 "<?xml version='1.0' encoding='utf-8'?>",
126 "<SoftwareIdentity tagId='msi:package/G-U-I-D' name='~Test Package' version='1.0.1' versionScheme='multipartnumeric' xmlns='http://standards.iso.org/iso/19770/-2/2015/schema.xsd'>",
127 " <Entity name='Example Corporation' regid='regid.1995-08.com.example' role='softwareCreator tagCreator' />",
128 " <Meta persistentId='msi:upgrade/7D326855-E790-4A94-8611-5351F8321FCA' />",
129 "</SoftwareIdentity>",
130 }), contents.Replace('"', '\''));
131 }
132 }
133
134 [Fact]
90 public void CanBuildSimplePatchWithBaselineIdTooLong() 135 public void CanBuildSimplePatchWithBaselineIdTooLong()
91 { 136 {
92 var folder = TestData.Get(@"TestData", "PatchBaselineIdTooLong"); 137 var folder = TestData.Get(@"TestData", "PatchBaselineIdTooLong");
@@ -192,12 +237,12 @@ namespace WixToolsetTest.CoreIntegration
192 } 237 }
193 } 238 }
194 239
195 private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB) 240 private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB, IEnumerable<string> bindpaths = null)
196 { 241 {
197 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); 242 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
198 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); 243 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
199 244
200 var result = WixRunner.Execute(new[] 245 var args = new List<string>
201 { 246 {
202 "build", 247 "build",
203 Path.Combine(sourceFolder, @"Package.wxs"), 248 Path.Combine(sourceFolder, @"Package.wxs"),
@@ -208,7 +253,15 @@ namespace WixToolsetTest.CoreIntegration
208 "-intermediateFolder", Path.Combine(baseFolder, "obj"), 253 "-intermediateFolder", Path.Combine(baseFolder, "obj"),
209 "-o", outputPath, 254 "-o", outputPath,
210 "-ext", extensionPath, 255 "-ext", extensionPath,
211 }); 256 };
257
258 foreach (var additionaBindPath in bindpaths ?? Enumerable.Empty<string>())
259 {
260 args.Add("-bindpath");
261 args.Add(additionaBindPath);
262 }
263
264 var result = WixRunner.Execute(args.ToArray());
212 265
213 result.AssertSuccess(); 266 result.AssertSuccess();
214 267
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt
new file mode 100644
index 00000000..6fd385bd
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt
@@ -0,0 +1 @@
This is A v1.0.0
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs
new file mode 100644
index 00000000..1b97e6b7
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs
@@ -0,0 +1,28 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="~Test Package" Version="$(V)" Manufacturer="Example Corporation" Language="1033" UpgradeCode="7d326855-e790-4a94-8611-5351f8321fca" Compressed="yes" Scope="perMachine" ProductCode="7d326855-e790-4a94-8611-5351f8321fca">
3 <SoftwareTag Regid="regid.1995-08.com.example" InstallDirectory="INSTALLFOLDER" />
4
5 <MajorUpgrade DowngradeErrorMessage="Newer version already installed." />
6 <MediaTemplate EmbedCab="yes" />
7
8 <StandardDirectory Id="ProgramFilesFolder">
9 <Directory Id="INSTALLFOLDER" Name="~Test App" />
10 </StandardDirectory>
11
12 <Feature Id="Main">
13 <ComponentGroupRef Id="Components" />
14 </Feature>
15 </Package>
16
17 <Fragment>
18 <ComponentGroup Id="Components" Directory="INSTALLFOLDER">
19 <Component>
20 <File Id="a.txt" Name="a.txt" Source="A.txt" />
21 </Component>
22
23 <Component>
24 <RegistryValue Root="HKLM" Key="SOFTWARE\!(bind.property.ProductName)\Patch" Name="Version" Value="$(V)" />
25 </Component>
26 </ComponentGroup>
27 </Fragment>
28</Wix>
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs
new file mode 100644
index 00000000..889b1220
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs
@@ -0,0 +1,16 @@
1<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
2 <Patch
3 AllowRemoval="yes"
4 DisplayName="~Test Patch v$(V)"
5 Description="~Test Small Update Patch v$(V)"
6 MoreInfoURL="http://www.example.com/"
7 Manufacturer="Example Corporation"
8 Classification="Update">
9
10 <Media Id="1" Cabinet="foo.cab">
11 <PatchBaseline Id="RTM" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb" />
12 </Media>
13
14 <PatchFamily Id='SequenceFamily' Version='$(V)' />
15 </Patch>
16</Wix>