Skip to content

Commit

Permalink
Add failing test for issue wixtoolset/issues#6298.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed Dec 21, 2020
1 parent 85deb61 commit 21ad61c
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/WixToolset.Core.TestPackage/BundleExtractor.cs
Expand Up @@ -44,6 +44,23 @@ public static ExtractBAContainerResult ExtractBAContainer(IMessaging messaging,
return result;
}

/// <summary>
/// Extracts detached and attached containers.
/// </summary>
/// <param name="messaging"></param>
/// <param name="bundleFilePath">Path to the bundle.</param>
/// <param name="destinationFolderPath">Path to extract to.</param>
/// <param name="tempFolderPath">Temp path for extraction.</param>
/// <returns></returns>
public static bool ExtractAttachedContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath)
{
Directory.CreateDirectory(tempFolderPath);
using (var burnReader = BurnReader.Open(messaging, bundleFilePath))
{
return burnReader.ExtractAttachedContainer(destinationFolderPath, tempFolderPath);
}
}

/// <summary>
/// Gets an <see cref="XmlNamespaceManager"/> for BootstrapperApplicationData.xml with the given prefix assigned to the root namespace.
/// </summary>
Expand Down
37 changes: 37 additions & 0 deletions src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
Expand Up @@ -348,5 +348,42 @@ public void CantBuildWithUnscheduledRollbackBoundary()
Assert.InRange(result.ExitCode, 2, Int32.MaxValue);
}
}

[Fact(Skip = "Test demonstrates failure https://github.com/wixtoolset/issues/issues/6298")]
public void CanDecompileBundleWithDettachedContainer()
{
var folder = TestData.Get(@"TestData\BundleWithDetachedContainer");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var exePath = Path.Combine(baseFolder, @"bin\test.exe");
var pdbPath = Path.Combine(baseFolder, @"bin\test.wixpdb");
var baFolderPath = Path.Combine(baseFolder, "ba");
var extractFolderPath = Path.Combine(baseFolder, "extract1");
var extractContainerFolderPath = Path.Combine(baseFolder, "extract2");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "Bundle.wxs"),
"-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
"-bindpath", Path.Combine(folder, "data"),
"-intermediateFolder", intermediateFolder,
"-o", exePath,
});

result.AssertSuccess();
Assert.Empty(result.Messages.Where(m => m.Level == MessageLevel.Warning));

Assert.True(File.Exists(exePath));
Assert.True(File.Exists(pdbPath));

Assert.True(BundleExtractor.ExtractAttachedContainer(null, exePath, extractFolderPath, extractContainerFolderPath));

//TODO Check that extracted files exist as expected
}
}
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file contains the declaration of all the localizable strings.
-->
<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">

<String Id="BundleName">~TestBundle</String>

</WixLocalization>
@@ -0,0 +1,21 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Bundle Name="!(loc.BundleName)" Version="!(bind.packageVersion.test.msi)" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<BootstrapperApplication>
<BootstrapperApplicationDll SourceFile="fakeba.dll" />
</BootstrapperApplication>
<Chain>
<PackageGroupRef Id="_1"/>
</Chain>
</Bundle>

<Fragment>
<PackageGroup Id="_1">
<MsiPackage SourceFile="test.msi">
<MsiProperty Name="TEST" Value="1" />
</MsiPackage>
</PackageGroup>
<Container Id="_1" Type="Detached">
<PackageGroupRef Id="_1"/>
</Container>
</Fragment>
</Wix>
@@ -0,0 +1,7 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<BootstrapperApplication Id="fakeba">
<BootstrapperApplicationDll SourceFile="fakeba.dll" />
</BootstrapperApplication>
</Fragment>
</Wix>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Bundle Name="!(loc.BundleName)" Version="!(bind.packageVersion.test.msi)" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<BootstrapperApplicationRef Id="fakeba">
<PayloadGroupRef Id="TestPayloadGroup" />
</BootstrapperApplicationRef>
<Chain>
<MsiPackage SourceFile="test.msi">
<MsiProperty Name="TEST" Value="1" />
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<PayloadGroup Id="TestPayloadGroup">
<Payload SourceFile="MsiPackage\test.txt" />
</PayloadGroup>
</Fragment>
</Wix>
@@ -0,0 +1 @@
This is Shared.dll.
@@ -0,0 +1 @@
This is test.txt
@@ -0,0 +1 @@
This is a fakeba.dll
Binary file not shown.
Expand Up @@ -7,6 +7,16 @@
<IsPackable>false</IsPackable>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="TestData\BundleWithDetachedContainer\Bundle.en-us.wxl" />
<None Remove="TestData\BundleWithDetachedContainer\Bundle.wxs" />
<None Remove="TestData\BundleWithDetachedContainer\data\fakeba.dll" />
<None Remove="TestData\BundleWithDetachedContainer\data\MsiPackage\Shared.dll" />
<None Remove="TestData\BundleWithDetachedContainer\data\MsiPackage\test.txt" />
<None Remove="TestData\BundleWithDetachedContainer\data\test.msi" />
<None Remove="TestData\BundleWithDetachedContainer\MultiFileBootstrapperApplication.wxs" />
<None Remove="TestData\BundleWithDetachedContainer\MultiFileBundle.wxs" />
</ItemGroup>

<ItemGroup>
<Content Include="TestData\.Data\burn.exe" CopyToOutputDirectory="PreserveNewest" />
Expand All @@ -32,6 +42,30 @@
<Content Include="TestData\BundleExtension\BundleExtensionSearches.wxs" CopyToOutputDirectory="PreserveNewest" />
<Content Include="TestData\BundleExtension\BundleWithSearches.wxs" CopyToOutputDirectory="PreserveNewest" />
<Content Include="TestData\BundleExtension\SimpleBundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" />
<Content Include="TestData\BundleWithDetachedContainer\Bundle.en-us.wxl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\Bundle.wxs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\data\fakeba.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\data\MsiPackage\Shared.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\data\MsiPackage\test.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\data\test.msi">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\MultiFileBootstrapperApplication.wxs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithDetachedContainer\MultiFileBundle.wxs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\BundleWithPackageGroupRef\Bundle.wxs" CopyToOutputDirectory="PreserveNewest" />
<Content Include="TestData\BundleWithPackageGroupRef\MinimalPackageGroup.wxs" CopyToOutputDirectory="PreserveNewest" />
<Content Include="TestData\Class\DecompiledOldClassTableDef.wxs" CopyToOutputDirectory="PreserveNewest" />
Expand Down

0 comments on commit 21ad61c

Please sign in to comment.