Update old test code to latest SWID tag spec
Fixes 6675
Rob Mensching committed
Aug 26, 2022 at 17:47 UTC
3e0e54aff605da9c5ec6c02f7e83d5e816c857a2
9 files changed
+121
-12
src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj
+3
@@ -5,6 +5,9 @@
5
<IncludeSoftwareTag>true</IncludeSoftwareTag>
6
<UpgradeCode>{AA083618-6280-44B8-9899-57BCC57906A5}</UpgradeCode>
7
</PropertyGroup>
8
+ <PropertyGroup>
9
+ <Version>1.0.1.0</Version>
10
+ </PropertyGroup>
11
<ItemGroup>
12
<Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
13
</ItemGroup>
src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj
+1
-2
@@ -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. -->
2
<Project Sdk="WixToolset.Sdk">
3
<PropertyGroup>
4
- <OutputType>PatchCreation</OutputType>
5
- <TargetExt>.msp</TargetExt>
4
+ <OutputType>Patch</OutputType>
5
<SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
6
</PropertyGroup>
7
<ItemGroup>
src/test/burn/TestData/Templates/Bundle.wxs
+1
-1
@@ -14,7 +14,7 @@
14
<Variable Name="TestGroupName" Value="$(var.TestGroupName)" />
15
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?>
19
20
<?ifndef BA?>
src/test/burn/TestData/Templates/Package.wxs
+7
-1
@@ -20,7 +20,7 @@
20
<?endif?>
21
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?>
25
26
<PropertyRef Id="TestVersion" />
@@ -35,6 +35,12 @@
35
</Package>
36
37
<Fragment>
38
+ <?ifdef SoftwareTag?>
39
+ <StandardDirectory Id="CommonAppDataFolder">
40
+ <Directory Id="SwidTagBaseFolder" Name="TestingSwidTags" />
41
+ </StandardDirectory>
42
+ <?endif?>
43
+
44
<StandardDirectory Id="ProgramFiles6432Folder">
45
<Directory Id="WixDir" Name="~Test WiX">
46
<Directory Id="TestDir" Name="$(var.TestGroupName)">
src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs
+8
-5
@@ -56,7 +56,7 @@ namespace WixToolsetTest.BurnE2E
56
packageAv1.VerifyTestRegistryRootDeleted();
57
}
58
59
- [RuntimeFact(Skip = "https://github.com/wixtoolset/issues/issues/6675")]
59
+ [RuntimeFact]
60
public void CanPatchSwidTag()
61
{
62
var originalVersion = "1.0.0.0";
@@ -116,8 +116,7 @@ namespace WixToolsetTest.BurnE2E
116
117
private static void VerifySwidTagVersion(string tagName, string expectedVersion)
118
{
119
- var regidFolder = Environment.ExpandEnvironmentVariables(@"%ProgramData%\regid.1995-08.com.example");
120
- var tagPath = Path.Combine(regidFolder, "regid.1995-08.com.example " + tagName + ".swidtag");
119
+ var tagPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "TestingSwidTags", "swidtag", tagName + ".swidtag");
120
string version = null;
121
122
if (File.Exists(tagPath))
@@ -126,11 +125,15 @@ namespace WixToolsetTest.BurnE2E
125
doc.Load(tagPath);
126
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");
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);
131
version = versionNode?.InnerText ?? String.Empty;
132
}
133
+ else
134
+ {
135
+ Assert.True(expectedVersion == null, $"Did not find SWID tag with expected version {expectedVersion} at: {tagPath}");
136
+ }
137
138
Assert.Equal(expectedVersion, version);
139
}
src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+56
-3
@@ -9,6 +9,7 @@ namespace WixToolsetTest.CoreIntegration
9
using System.Linq;
10
using System.Runtime.InteropServices;
11
using System.Text;
12
+ using System.Text.RegularExpressions;
13
using System.Xml;
14
using System.Xml.Linq;
15
using Example.Extension;
@@ -86,6 +87,50 @@ namespace WixToolsetTest.CoreIntegration
87
}
88
}
89
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]
135
public void CanBuildSimplePatchWithBaselineIdTooLong()
136
{
@@ -192,12 +237,12 @@ namespace WixToolsetTest.CoreIntegration
237
}
238
}
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)
241
{
242
var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
243
var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
244
200
- var result = WixRunner.Execute(new[]
245
+ var args = new List<string>
246
{
247
"build",
248
Path.Combine(sourceFolder, @"Package.wxs"),
@@ -208,7 +253,15 @@ namespace WixToolsetTest.CoreIntegration
253
"-intermediateFolder", Path.Combine(baseFolder, "obj"),
254
"-o", outputPath,
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());
265
266
result.AssertSuccess();
267
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt
new
+1
@@ -0,0 +1 @@
1
+This is A v1.0.0
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs
new
+28
@@ -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>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs
new
+16
@@ -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>