@joebigelow / wix / commits / 42727c42

Bug: Wixipl references to extension libraries

Add test demonstrating that a persisted .wixipl file has broken references to bits in an extension's library. Same project built via wix.exe in one pass works as expected.

Bob Arnson committed Mar 20, 2019 at 21:18 UTC 42727c42248d1cb12ef8d9bc6f8ce7dda3f404c9
6 files changed +150
src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.en-us.wxl new
+11
@@ -0,0 +1,11 @@
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="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 + <String Id="FeatureTitle">MsiPackage</String>
10 +
11 +</WixLocalization>
src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.wxs new
+23
@@ -0,0 +1,23 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Product Id="*" Name="MsiPackage" Codepage="1252" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 + <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
5 +
6 + <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 + <MediaTemplate />
8 +
9 + <CustomAction Id="CAFromExtension" BinaryKey="BinFromWir" DllEntry="DoesntExist" />
10 +
11 + <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
12 + <ComponentGroupRef Id="ProductComponents" />
13 + </Feature>
14 + </Product>
15 +
16 + <Fragment>
17 + <Directory Id="TARGETDIR" Name="SourceDir">
18 + <Directory Id="ProgramFilesFolder">
19 + <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
20 + </Directory>
21 + </Directory>
22 + </Fragment>
23 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/PackageComponents.wxs new
+10
@@ -0,0 +1,10 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5 + <Component>
6 + <File Source="test.txt" />
7 + </Component>
8 + </ComponentGroup>
9 + </Fragment>
10 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/data/test.txt new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+4
@@ -81,6 +81,10 @@
81 <Content Include="TestData\OverridableActions\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
82 <Content Include="TestData\OverridableActions\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
83 <Content Include="TestData\OverridableActions\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
84 + <Content Include="TestData\Wixipl\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
85 + <Content Include="TestData\Wixipl\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
86 + <Content Include="TestData\Wixipl\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
87 + <Content Include="TestData\Wixipl\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
88 </ItemGroup>
89
90 <ItemGroup>
src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs
+101
@@ -2,12 +2,14 @@
2
3 namespace WixToolsetTest.CoreIntegration
4 {
5 + using System;
6 using System.IO;
7 using System.Linq;
8 using WixBuildTools.TestSupport;
9 using WixToolset.Core.TestPackage;
10 using WixToolset.Data;
11 using WixToolset.Data.Tuples;
12 + using Example.Extension;
13 using Xunit;
14
15 public class WixiplFixture
@@ -88,5 +90,104 @@ namespace WixToolsetTest.CoreIntegration
90 Assert.Equal((int)ErrorMessages.Ids.WixiplSourceFileIsExclusive, result.ExitCode);
91 }
92 }
93 +
94 + [Fact]
95 + public void CanBuildMsiUsingExtensionLibrary()
96 + {
97 + var folder = TestData.Get(@"TestData\Wixipl");
98 + var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
99 +
100 + using (var fs = new DisposableFileSystem())
101 + {
102 + var baseFolder = fs.GetFolder();
103 + var intermediateFolder = Path.Combine(baseFolder, "obj");
104 +
105 + var result = WixRunner.Execute(new[]
106 + {
107 + "build",
108 + "-ext", extensionPath,
109 + Path.Combine(folder, "Package.wxs"),
110 + Path.Combine(folder, "PackageComponents.wxs"),
111 + "-loc", Path.Combine(folder, "Package.en-us.wxl"),
112 + "-bindpath", Path.Combine(folder, "data"),
113 + "-intermediateFolder", intermediateFolder,
114 + "-o", Path.Combine(baseFolder, @"bin\test.msi"),
115 + });
116 +
117 + result.AssertSuccess();
118 +
119 + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir"));
120 + var section = intermediate.Sections.Single();
121 +
122 + {
123 + var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
124 + Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
125 + Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
126 + }
127 +
128 + {
129 + var binary = section.Tuples.OfType<BinaryTuple>().Single();
130 + var path = binary[BinaryTupleFields.Data].AsPath().Path;
131 + Assert.Contains("Example.Extension", path);
132 + Assert.EndsWith(@"\0", path);
133 + Assert.Equal(@"BinFromWir", binary[BinaryTupleFields.Name].AsString());
134 + }
135 + }
136 + }
137 +
138 + [Fact]
139 + public void CanBuildWixiplUsingExtensionLibrary()
140 + {
141 + var folder = TestData.Get(@"TestData\Wixipl");
142 + var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
143 +
144 + using (var fs = new DisposableFileSystem())
145 + {
146 + var baseFolder = fs.GetFolder();
147 + var intermediateFolder = Path.Combine(baseFolder, "obj");
148 +
149 + var result = WixRunner.Execute(new[]
150 + {
151 + "build",
152 + "-ext", extensionPath,
153 + Path.Combine(folder, "Package.wxs"),
154 + Path.Combine(folder, "PackageComponents.wxs"),
155 + "-intermediateFolder", intermediateFolder,
156 + "-o", Path.Combine(intermediateFolder, @"test.wixipl"),
157 + });
158 +
159 + result.AssertSuccess();
160 +
161 + result = WixRunner.Execute(new[]
162 + {
163 + "build",
164 + Path.Combine(intermediateFolder, @"test.wixipl"),
165 + "-ext", extensionPath,
166 + "-loc", Path.Combine(folder, "Package.en-us.wxl"),
167 + "-bindpath", Path.Combine(folder, "data"),
168 + "-intermediateFolder", intermediateFolder,
169 + "-o", Path.Combine(baseFolder, @"bin\test.msi"),
170 + });
171 +
172 + result.AssertSuccess();
173 +
174 + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir"));
175 + var section = intermediate.Sections.Single();
176 +
177 + {
178 + var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
179 + Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
180 + Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
181 + }
182 +
183 + {
184 + var binary = section.Tuples.OfType<BinaryTuple>().Single();
185 + var path = binary[BinaryTupleFields.Data].AsPath().Path;
186 + Assert.Contains("Example.Extension", path);
187 + Assert.EndsWith(@"\0", path);
188 + Assert.Equal(@"BinFromWir", binary[BinaryTupleFields.Name].AsString());
189 + }
190 + }
191 + }
192 }
193 }