@joebigelow / wix / commits / da8727b1

Use strongly-typed tuple creation...

...especially for tuples shared with WixToolset.Data. Add bundle tests.

Bob Arnson committed Oct 23, 2019 at 21:25 UTC da8727b126a3dc358c9d265c6e183b151ed8ec44
13 files changed +159 -75
src/FindLocalWix.props
+1 -1
@@ -3,6 +3,6 @@
3
4 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <PropertyGroup>
6 - <WixTargetsPath Condition=" '$(Configuration)' == 'Debug' And Exists('$(MSBuildThisFileDirectory)..\..\Tools\README.md') ">$(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets</WixTargetsPath>
6 + <WixTargetsPath Condition=" '$(Configuration)' == 'Debug' And Exists('$(MSBuildThisFileDirectory)..\..\Tools\README.md') And Exists('$(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets') ">$(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets</WixTargetsPath>
7 </PropertyGroup>
8 </Project>
src/test/WixToolsetTest.Util/TestData/.Data/burn.exe
Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/.Data/burn.exe differ
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/Bundle.en-us.wxl new
+10
@@ -0,0 +1,10 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<!--
4 +This file contains the declaration of all the localizable strings.
5 +-->
6 +<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7 +
8 + <String Id="BundleName">~TestBundle</String>
9 +
10 +</WixLocalization>
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/Bundle.wxs new
+35
@@ -0,0 +1,35 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 + xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
4 + <Bundle Name="!(loc.BundleName)" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
5 + <BootstrapperApplication SourceFile="fakeba.dll" />
6 +
7 + <util:RegistrySearchRef Id="RegistrySearchId" />
8 + <util:ProductSearchRef Id="ProductSearchId" />
9 + <util:FileSearchRef Id="FileSearchId" />
10 +
11 + <Chain>
12 + <MsiPackage SourceFile="test.msi">
13 + <MsiProperty Name="TEST" Value="1" />
14 + </MsiPackage>
15 + </Chain>
16 + </Bundle>
17 +
18 + <Fragment>
19 + <util:RegistrySearch
20 + Id="RegistrySearchId"
21 + Variable="RegistrySearchVariable"
22 + Root="HKLM"
23 + Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
24 + Value="Release"
25 + Result="value" />
26 + </Fragment>
27 +
28 + <Fragment>
29 + <util:ProductSearch Id="ProductSearchId" Variable="ProductSearchVariable" UpgradeCode="738D02BF-E231-4370-8209-E9FD4E1BE2A1" Condition="1 &amp; 2 &lt; 3" Result="version" />
30 + </Fragment>
31 +
32 + <Fragment>
33 + <util:FileSearch Id="FileSearchId" Variable="FileSearchVariable" Path="%windir%\System32\mscoree.dll" Result="exists" />
34 + </Fragment>
35 +</Wix>
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/data/MsiPackage/Shared.dll new
+1
@@ -0,0 +1 @@
1 +This is Shared.dll.
\ No newline at end of file
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/data/MsiPackage/test.txt new
+1
@@ -0,0 +1 @@
1 +This is test.txt
\ No newline at end of file
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/data/fakeba.dll new
+1
@@ -0,0 +1 @@
1 +This is a fakeba.dll
\ No newline at end of file
src/test/WixToolsetTest.Util/TestData/BundleWithSearches/data/test.msi
Binary files /dev/null and b/src/test/WixToolsetTest.Util/TestData/BundleWithSearches/data/test.msi differ
src/test/WixToolsetTest.Util/UtilExtensionFixture.cs
+67
@@ -2,9 +2,12 @@
2
3 namespace WixToolsetTest.Util
4 {
5 + using System.IO;
6 using System.Linq;
7 using WixBuildTools.TestSupport;
8 using WixToolset.Core.TestPackage;
9 + using WixToolset.Data;
10 + using WixToolset.Data.Tuples;
11 using WixToolset.Util;
12 using Xunit;
13
@@ -24,6 +27,70 @@ namespace WixToolsetTest.Util
27 }, results.OrderBy(s => s).ToArray());
28 }
29
30 + [Fact]
31 + public void CanBuildBundleWithSearches()
32 + {
33 + var burnStubPath = TestData.Get(@"TestData\.Data\burn.exe");
34 + var folder = TestData.Get(@"TestData\BundleWithSearches");
35 + var rootFolder = TestData.Get();
36 + var wixext = Path.Combine(rootFolder, "WixToolset.Util.wixext.dll");
37 +
38 + using (var fs = new DisposableFileSystem())
39 + {
40 + var baseFolder = fs.GetFolder();
41 + var intermediateFolder = Path.Combine(baseFolder, "obj");
42 +
43 + var result = WixRunner.Execute(new[]
44 + {
45 + "build",
46 + Path.Combine(folder, "Bundle.wxs"),
47 + "-ext", wixext,
48 + "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
49 + "-bindpath", Path.Combine(folder, "data"),
50 + "-intermediateFolder", intermediateFolder,
51 + "-burnStub", burnStubPath,
52 + "-o", Path.Combine(baseFolder, @"bin\test.exe")
53 + });
54 +
55 + result.AssertSuccess();
56 +
57 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.exe")));
58 +#if TODO
59 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));
60 +#endif
61 +
62 + var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir"));
63 + var section = intermediate.Sections.Single();
64 +
65 + var searchTuples = section.Tuples.OfType<WixSearchTuple>().OrderBy(t => t.Id.Id).ToList();
66 + Assert.Equal(3, searchTuples.Count);
67 + Assert.Equal("FileSearchId", searchTuples[0].Id.Id);
68 + Assert.Equal("FileSearchVariable", searchTuples[0].Variable);
69 + Assert.Equal("ProductSearchId", searchTuples[1].Id.Id);
70 + Assert.Equal("ProductSearchVariable", searchTuples[1].Variable);
71 + Assert.Equal("1 & 2 < 3", searchTuples[1].Condition);
72 + Assert.Equal("RegistrySearchId", searchTuples[2].Id.Id);
73 + Assert.Equal("RegistrySearchVariable", searchTuples[2].Variable);
74 +
75 + var fileSearchTuple = section.Tuples.OfType<WixFileSearchTuple>().Single();
76 + Assert.Equal("FileSearchId", fileSearchTuple.Id.Id);
77 + Assert.Equal(@"%windir%\System32\mscoree.dll", fileSearchTuple.Path);
78 + Assert.Equal(WixFileSearchAttributes.Default | WixFileSearchAttributes.WantExists, fileSearchTuple.Attributes);
79 +
80 + var productSearchTuple = section.Tuples.OfType<WixProductSearchTuple>().Single();
81 + Assert.Equal("ProductSearchId", productSearchTuple.Id.Id);
82 + Assert.Equal("{738D02BF-E231-4370-8209-E9FD4E1BE2A1}", productSearchTuple.Guid);
83 + Assert.Equal(WixProductSearchAttributes.Version | WixProductSearchAttributes.UpgradeCode, productSearchTuple.Attributes);
84 +
85 + var registrySearchTuple = section.Tuples.OfType<WixRegistrySearchTuple>().Single();
86 + Assert.Equal("RegistrySearchId", registrySearchTuple.Id.Id);
87 + Assert.Equal(RegistryRootType.LocalMachine, registrySearchTuple.Root);
88 + Assert.Equal(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", registrySearchTuple.Key);
89 + Assert.Equal("Release", registrySearchTuple.Value);
90 + Assert.Equal(WixRegistrySearchAttributes.WantValue | WixRegistrySearchAttributes.Raw, registrySearchTuple.Attributes);
91 + }
92 + }
93 +
94 private static void Build(string[] args)
95 {
96 var result = WixRunner.Execute(args)
src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj
+7
@@ -12,6 +12,13 @@
12 </PropertyGroup>
13
14 <ItemGroup>
15 + <Content Include="TestData\.Data\burn.exe" CopyToOutputDirectory="PreserveNewest" />
16 + <Content Include="TestData\BundleWithSearches\data\fakeba.dll" CopyToOutputDirectory="PreserveNewest" />
17 + <Content Include="TestData\BundleWithSearches\data\MsiPackage\Shared.dll" CopyToOutputDirectory="PreserveNewest" />
18 + <Content Include="TestData\BundleWithSearches\data\MsiPackage\test.txt" CopyToOutputDirectory="PreserveNewest" />
19 + <Content Include="TestData\BundleWithSearches\data\test.msi" CopyToOutputDirectory="PreserveNewest" />
20 + <Content Include="TestData\BundleWithSearches\Bundle.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
21 + <Content Include="TestData\BundleWithSearches\Bundle.wxs" CopyToOutputDirectory="PreserveNewest" />
22 <Content Include="TestData\UsingFileShare\example.txt" CopyToOutputDirectory="PreserveNewest" />
23 <Content Include="TestData\UsingFileShare\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
24 <Content Include="TestData\UsingFileShare\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
src/wixext/UtilCompiler.cs
+33 -71
@@ -34,55 +34,12 @@ namespace WixToolset.Util
34 internal const int UserDontCreateUser = 0x00000200;
35 internal const int UserNonVital = 0x00000400;
36
37 - [Flags]
38 - internal enum WixFileSearchAttributes
39 - {
40 - Default = 0x001,
41 - MinVersionInclusive = 0x002,
42 - MaxVersionInclusive = 0x004,
43 - MinSizeInclusive = 0x008,
44 - MaxSizeInclusive = 0x010,
45 - MinDateInclusive = 0x020,
46 - MaxDateInclusive = 0x040,
47 - WantVersion = 0x080,
48 - WantExists = 0x100,
49 - IsDirectory = 0x200,
50 - }
51 -
37 internal enum WixRegistrySearchFormat
38 {
39 Raw,
40 Compatible,
41 }
42
58 - [Flags]
59 - internal enum WixRegistrySearchAttributes
60 - {
61 - Raw = 0x01,
62 - Compatible = 0x02,
63 - ExpandEnvironmentVariables = 0x04,
64 - WantValue = 0x08,
65 - WantExists = 0x10,
66 - Win64 = 0x20,
67 - }
68 -
69 - internal enum WixComponentSearchAttributes
70 - {
71 - KeyPath = 0x1,
72 - State = 0x2,
73 - WantDirectory = 0x4,
74 - }
75 -
76 - [Flags]
77 - internal enum WixProductSearchAttributes
78 - {
79 - Version = 0x01,
80 - Language = 0x02,
81 - State = 0x04,
82 - Assignment = 0x08,
83 - UpgradeCode = 0x10,
84 - }
85 -
43 internal enum WixRestartResourceAttributes
44 {
45 Filename = 1,
@@ -505,10 +462,12 @@ namespace WixToolset.Util
462 break;
463 }
464
508 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixComponentSearch", id);
509 - row.Set(1, guid);
510 - row.Set(2, productCode);
511 - row.Set(3, (int)attributes);
465 + section.Tuples.Add(new WixComponentSearchTuple(sourceLineNumbers, id)
466 + {
467 + Guid = guid,
468 + ProductCode = productCode,
469 + Attributes = attributes,
470 + });
471 }
472 }
473
@@ -1087,16 +1046,11 @@ namespace WixToolset.Util
1046 /// <param name="attributes"></param>
1047 private void CreateWixFileSearchRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string path, WixFileSearchAttributes attributes)
1048 {
1090 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixFileSearch", id);
1091 - row.Set(1, path);
1092 - //row.Set(2, minVersion;
1093 - //row.Set(3, maxVersion;
1094 - //row.Set(4, minSize;
1095 - //row.Set(5, maxSize;
1096 - //row.Set(6, minDate;
1097 - //row.Set(7, maxDate;
1098 - //row.Set(8, languages;
1099 - row.Set(9, (int)attributes);
1049 + section.Tuples.Add(new WixFileSearchTuple(sourceLineNumbers, id)
1050 + {
1051 + Path = path,
1052 + Attributes = attributes,
1053 + });
1054 }
1055
1056 /// <summary>
@@ -1108,9 +1062,11 @@ namespace WixToolset.Util
1062 /// <param name="condition">A condition to test before evaluating the search.</param>
1063 private void CreateWixSearchRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string variable, string condition)
1064 {
1111 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixSearch", id);
1112 - row.Set(1, variable);
1113 - row.Set(2, condition);
1065 + section.Tuples.Add(new WixSearchTuple(sourceLineNumbers, id)
1066 + {
1067 + Variable = variable,
1068 + Condition = condition,
1069 + });
1070 }
1071
1072 /// <summary>
@@ -1122,9 +1078,11 @@ namespace WixToolset.Util
1078 /// <param name="attributes">Further details about the relation between id and parentId.</param>
1079 private void CreateWixSearchRelationRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes)
1080 {
1125 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixSearchRelation", id);
1126 - row.Set(1, parentId);
1127 - row.Set(2, attributes);
1081 + section.Tuples.Add(new WixSearchRelationTuple(sourceLineNumbers, id)
1082 + {
1083 + ParentSearchRef = parentId,
1084 + Attributes = attributes,
1085 + });
1086 }
1087
1088 /// <summary>
@@ -2680,9 +2638,11 @@ namespace WixToolset.Util
2638 attributes |= WixProductSearchAttributes.UpgradeCode;
2639 }
2640
2683 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixProductSearch", id);
2684 - row.Set(1, productCode ?? upgradeCode);
2685 - row.Set(2, (int)attributes);
2641 + section.Tuples.Add(new WixProductSearchTuple(sourceLineNumbers, id)
2642 + {
2643 + Guid = productCode ?? upgradeCode,
2644 + Attributes = attributes,
2645 + });
2646 }
2647 }
2648
@@ -2836,11 +2796,13 @@ namespace WixToolset.Util
2796 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
2797 }
2798
2839 - var row = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "WixRegistrySearch", id);
2840 - row.Set(1, (int)root);
2841 - row.Set(2, key);
2842 - row.Set(3, value);
2843 - row.Set(4, (int)attributes);
2799 + section.Tuples.Add(new WixRegistrySearchTuple(sourceLineNumbers, id)
2800 + {
2801 + Root = (RegistryRootType)root,
2802 + Key = key,
2803 + Value = value,
2804 + Attributes = attributes,
2805 + });
2806 }
2807 }
2808
src/wixlib/packages.config
+1 -1
@@ -1,5 +1,5 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <packages>
3 <package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" />
4 - <package id="WixToolset.MSBuild" version="4.0.0-build-0043" developmentDependency="true" targetFramework="net40" />
4 + <package id="WixToolset.MSBuild" version="4.0.0-build-0048" developmentDependency="true" targetFramework="net40" />
5 </packages>
\ No newline at end of file
src/wixlib/util.wixproj
+2 -2
@@ -1,7 +1,7 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <!-- 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. -->
3 <Project DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">
4 - <Import Project="..\..\packages\WixToolset.MSBuild.4.0.0-build-0043\build\WixToolset.MSBuild.props" Condition="Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0043\build\WixToolset.MSBuild.props')" />
4 + <Import Project="..\..\packages\WixToolset.MSBuild.4.0.0-build-0048\build\WixToolset.MSBuild.props" Condition="Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0048\build\WixToolset.MSBuild.props')" />
5 <Import Project="..\FindLocalWix.props" />
6 <PropertyGroup>
7 <ProjectGuid>{1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}</ProjectGuid>
@@ -46,7 +46,7 @@
46 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
47 </PropertyGroup>
48 <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" />
49 - <Error Condition="!Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0043\build\WixToolset.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.MSBuild.4.0.0-build-0043\build\WixToolset.MSBuild.props'))" />
49 + <Error Condition="!Exists('..\..\packages\WixToolset.MSBuild.4.0.0-build-0048\build\WixToolset.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.MSBuild.4.0.0-build-0048\build\WixToolset.MSBuild.props'))" />
50 </Target>
51 <Import Project="..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" />
52 </Project>