@joebigelow / wix / commits / 301388ab

Add failing unit test for .NET assemblies

Bob Arnson committed Jan 8, 2018 at 13:12 UTC 301388abc7bfe230630e33bfd96ae4af43d59fb0
6 files changed +86
src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs
+40
@@ -317,6 +317,46 @@ namespace WixToolsetTest.CoreIntegration
317 }
318 }
319
320 + [Fact]
321 + public void CanBuildWithAssembly()
322 + {
323 + var folder = TestData.Get(@"TestData\Assembly");
324 +
325 + using (var fs = new DisposableFileSystem())
326 + {
327 + var baseFolder = fs.GetFolder();
328 + var intermediateFolder = Path.Combine(baseFolder, "obj");
329 +
330 + var program = new Program();
331 + var result = program.Run(new WixToolsetServiceProvider(), null, new[]
332 + {
333 + "build",
334 + Path.Combine(folder, "Package.wxs"),
335 + Path.Combine(folder, "PackageComponents.wxs"),
336 + "-loc", Path.Combine(folder, "Package.en-us.wxl"),
337 + "-bindpath", Path.Combine(folder, "data"),
338 + "-intermediateFolder", intermediateFolder,
339 + "-o", Path.Combine(baseFolder, @"bin\test.msi")
340 + });
341 +
342 + Assert.Equal(0, result);
343 +
344 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
345 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));
346 + Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\AssemblyMsiPackage\candle.exe")));
347 +
348 + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wir"));
349 + var section = intermediate.Sections.Single();
350 +
351 + var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
352 + Assert.Equal(Path.Combine(folder, @"data\candle.exe"), wixFile[WixFileTupleFields.Source].AsPath().Path);
353 + Assert.Equal(@"candle.exe", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
354 +
355 + var msiAssemblyNameTuples = section.Tuples.OfType<MsiAssemblyNameTuple>();
356 + Assert.NotEmpty(msiAssemblyNameTuples);
357 + }
358 + }
359 +
360 [Fact(Skip = "Not implemented yet.")]
361 public void CanBuildInstanceTransform()
362 {
src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/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/Assembly/Package.wxs new
+21
@@ -0,0 +1,21 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Product Id="*" Name="AssemblyMsiPackage" 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 + <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
10 + <ComponentGroupRef Id="ProductComponents" />
11 + </Feature>
12 + </Product>
13 +
14 + <Fragment>
15 + <Directory Id="TARGETDIR" Name="SourceDir">
16 + <Directory Id="ProgramFilesFolder">
17 + <Directory Id="INSTALLFOLDER" Name="AssemblyMsiPackage" />
18 + </Directory>
19 + </Directory>
20 + </Fragment>
21 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/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="candle.exe" Assembly=".net" />
7 + </Component>
8 + </ComponentGroup>
9 + </Fragment>
10 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/data/candle.exe
Binary files /dev/null and b/src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/data/candle.exe differ
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+4
@@ -44,6 +44,10 @@
44 <Content Include="TestData\ManualUpgrade\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
45 <Content Include="TestData\ManualUpgrade\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
46 <Content Include="TestData\ManualUpgrade\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
47 + <Content Include="TestData\Assembly\data\candle.exe" CopyToOutputDirectory="PreserveNewest" />
48 + <Content Include="TestData\Assembly\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
49 + <Content Include="TestData\Assembly\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
50 + <Content Include="TestData\Assembly\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
51 </ItemGroup>
52
53 <ItemGroup>