From ecf3a0cca5a424a91ab98557d963d2535963d582 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 22 Dec 2017 15:53:01 -0800 Subject: Reintroduce binder extensions and light.exe for binding .wixouts --- .../LightFixture.cs | 48 ++++++++++++ .../TestData/Wixout/Package.en-us.wxl | 11 +++ .../TestData/Wixout/data/test.txt | 1 + .../TestData/Wixout/test.wixout | Bin 0 -> 10354 bytes .../Utility/DisposableFileSystem.cs | 86 +++++++++++++++++++++ .../Utility/TestData.cs | 17 ++++ .../WixToolsetTest.LightIntegration.csproj | 33 ++++++++ 7 files changed, 196 insertions(+) create mode 100644 src/test/WixToolsetTest.LightIntegration/LightFixture.cs create mode 100644 src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt create mode 100644 src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout create mode 100644 src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs create mode 100644 src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs create mode 100644 src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj (limited to 'src/test/WixToolsetTest.LightIntegration') diff --git a/src/test/WixToolsetTest.LightIntegration/LightFixture.cs b/src/test/WixToolsetTest.LightIntegration/LightFixture.cs new file mode 100644 index 00000000..21c10be9 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/LightFixture.cs @@ -0,0 +1,48 @@ +// 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. + +namespace WixToolsetTest.LightIntegration +{ + using System.IO; + using System.Linq; + using WixToolset.Core; + using WixToolset.Tools; + using WixToolsetTest.LightIntegration.Utility; + using Xunit; + + public class LightFixture + { + [Fact] + public void CanBuildFromWixout() + { + var folder = TestData.Get(@"TestData\Wixout"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var program = new Light(); + var result = program.Run(new WixToolsetServiceProvider(), null, new[] + { + Path.Combine(folder, "test.wixout"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-b", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }); + + Assert.Equal(0, result); + + var binFolder = Path.Combine(baseFolder, @"bin\"); + var builtFiles = Directory.GetFiles(binFolder, "*", SearchOption.AllDirectories); + + Assert.Equal(new[]{ + "MsiPackage\\test.txt", + "test.msi", + "test.wir", + "test.wixpdb", + }, builtFiles.Select(f => f.Substring(binFolder.Length)).OrderBy(s => s).ToArray()); + } + } + } +} diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout new file mode 100644 index 00000000..009b625f Binary files /dev/null and b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout differ diff --git a/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs new file mode 100644 index 00000000..3b8c0e19 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs @@ -0,0 +1,86 @@ +// 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. + +namespace WixToolsetTest.LightIntegration.Utility +{ + using System; + using System.Collections.Generic; + using System.IO; + + public class DisposableFileSystem : IDisposable + { + protected bool Disposed { get; private set; } + + private List CleanupPaths { get; } = new List(); + + protected string GetFile(bool create = false) + { + var path = Path.GetTempFileName(); + + if (!create) + { + File.Delete(path); + } + + this.CleanupPaths.Add(path); + + return path; + } + + public string GetFolder(bool create = false) + { + var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + + if (create) + { + Directory.CreateDirectory(path); + } + + this.CleanupPaths.Add(path); + + return path; + } + + + #region // IDisposable + + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (this.Disposed) + { + return; + } + + if (disposing) + { + foreach (var path in this.CleanupPaths) + { + try + { + if (File.Exists(path)) + { + File.Delete(path); + } + else if (Directory.Exists(path)) + { + Directory.Delete(path, true); + } + } + catch + { + // Best effort delete, so ignore any failures. + } + } + } + + this.Disposed = true; + } + + #endregion + } +} diff --git a/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs b/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs new file mode 100644 index 00000000..c13e9d6d --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs @@ -0,0 +1,17 @@ +// 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. + +namespace WixToolsetTest.LightIntegration.Utility +{ + using System; + using System.IO; + + public class TestData + { + public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); + + public static string Get(params string[] paths) + { + return Path.Combine(LocalPath, Path.Combine(paths)); + } + } +} diff --git a/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj b/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj new file mode 100644 index 00000000..ef303868 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj @@ -0,0 +1,33 @@ + + + + + + net461 + false + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb