diff --git a/WixBuildTools.sln b/WixBuildTools.sln
index d7f2162..b46c4ed 100644
--- a/WixBuildTools.sln
+++ b/WixBuildTools.sln
@@ -1,13 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26730.3
+VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 15.0.26124.0
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{00E50075-E896-42D1-AC30-2D2E7D129FB9}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.XsdGen", "src\WixBuildTools.XsdGen\WixBuildTools.XsdGen.csproj", "{E89E52C9-A4A1-4174-A1B1-3B72975E6ED6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.MsgGen", "src\WixBuildTools.MsgGen\WixBuildTools.MsgGen.csproj", "{DB6EF6F3-51B1-4214-9A14-D501C23F6FA4}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.TestSupport", "src\WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj", "{6C57EF2C-979A-4106-A9E5-FE342810619A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -42,14 +42,22 @@ Global
{DB6EF6F3-51B1-4214-9A14-D501C23F6FA4}.Release|x64.Build.0 = Release|Any CPU
{DB6EF6F3-51B1-4214-9A14-D501C23F6FA4}.Release|x86.ActiveCfg = Release|Any CPU
{DB6EF6F3-51B1-4214-9A14-D501C23F6FA4}.Release|x86.Build.0 = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|x64.Build.0 = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Debug|x86.Build.0 = Debug|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x64.ActiveCfg = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x64.Build.0 = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x86.ActiveCfg = Release|Any CPU
+ {6C57EF2C-979A-4106-A9E5-FE342810619A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {E89E52C9-A4A1-4174-A1B1-3B72975E6ED6} = {00E50075-E896-42D1-AC30-2D2E7D129FB9}
- {DB6EF6F3-51B1-4214-9A14-D501C23F6FA4} = {00E50075-E896-42D1-AC30-2D2E7D129FB9}
- EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83E9E075-B440-471A-9C37-9D84BA0AE3E0}
EndGlobalSection
diff --git a/nuget.config b/nuget.config
index 6e1ad9b..fcbac27 100644
--- a/nuget.config
+++ b/nuget.config
@@ -2,6 +2,7 @@
+
\ No newline at end of file
diff --git a/src/WixBuildTools.TestSupport/Builder.cs b/src/WixBuildTools.TestSupport/Builder.cs
new file mode 100644
index 0000000..62439ff
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/Builder.cs
@@ -0,0 +1,113 @@
+// 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 WixBuildTools.TestSupport
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Text;
+ using WixToolset.Dtf.WindowsInstaller;
+
+ public class Builder
+ {
+ public Builder(string sourceFolder, Type extensionType = null, string[] bindPaths = null)
+ {
+ this.SourceFolder = sourceFolder;
+ this.ExtensionType = extensionType;
+ this.BindPaths = bindPaths;
+ }
+
+ public string[] BindPaths { get; }
+
+ public Type ExtensionType { get; }
+
+ public string SourceFolder { get; }
+
+ public string[] BuildAndQuery(Action buildFunc, params string[] tables)
+ {
+ var sourceFiles = Directory.GetFiles(this.SourceFolder, "*.wxs");
+ var wxlFiles = Directory.GetFiles(this.SourceFolder, "*.wxl");
+
+ using (var fs = new DisposableFileSystem())
+ {
+ var intermediateFolder = fs.GetFolder();
+ var outputPath = Path.Combine(intermediateFolder, @"bin\test.msi");
+
+ var args = new List
+ {
+ "build",
+ "-o", outputPath,
+ "-intermediateFolder", intermediateFolder,
+ };
+
+ if (this.ExtensionType != null)
+ {
+ args.Add("-ext");
+ args.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
+ }
+
+ args.AddRange(sourceFiles);
+
+ foreach (var wxlFile in wxlFiles)
+ {
+ args.Add("-loc");
+ args.Add(wxlFile);
+ }
+
+ foreach (var bindPath in this.BindPaths)
+ {
+ args.Add("-bindpath");
+ args.Add(bindPath);
+ }
+
+ buildFunc(args.ToArray());
+
+ return this.Query(outputPath, tables);
+ }
+ }
+
+ private string[] Query(string path, string[] tables)
+ {
+ var results = new List();
+
+ if (tables?.Length > 0)
+ {
+ var sb = new StringBuilder();
+ using (var db = new Database(path))
+ {
+ foreach (var table in tables)
+ {
+ using (var view = db.OpenView($"SELECT * FROM `{table}`"))
+ {
+ view.Execute();
+
+ Record record;
+ while ((record = view.Fetch()) != null)
+ {
+ sb.Clear();
+ sb.AppendFormat("{0}:", table);
+
+ using (record)
+ {
+ for (var i = 0; i < record.FieldCount; ++i)
+ {
+ if (i > 0)
+ {
+ sb.Append("\t");
+ }
+
+ sb.Append(record[i + 1]?.ToString());
+ }
+ }
+
+ results.Add(sb.ToString());
+ }
+ }
+ }
+ }
+ }
+
+ return results.ToArray();
+ }
+ }
+}
diff --git a/src/WixBuildTools.TestSupport/DisposableFileSystem.cs b/src/WixBuildTools.TestSupport/DisposableFileSystem.cs
new file mode 100644
index 0000000..28440f9
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/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 WixBuildTools.TestSupport
+{
+ 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/WixBuildTools.TestSupport/Pushd.cs b/src/WixBuildTools.TestSupport/Pushd.cs
new file mode 100644
index 0000000..d054521
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/Pushd.cs
@@ -0,0 +1,46 @@
+// 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 WixBuildTools.TestSupport
+{
+ using System;
+ using System.IO;
+
+ public class Pushd : IDisposable
+ {
+ protected bool Disposed { get; private set; }
+
+ public Pushd(string path)
+ {
+ this.PreviousDirectory = Directory.GetCurrentDirectory();
+
+ Directory.SetCurrentDirectory(path);
+ }
+
+ public string PreviousDirectory { get; }
+
+ #region // IDisposable
+
+ public void Dispose()
+ {
+ this.Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (this.Disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ Directory.SetCurrentDirectory(this.PreviousDirectory);
+ }
+
+ this.Disposed = true;
+ }
+
+ #endregion
+ }
+}
diff --git a/src/WixBuildTools.TestSupport/TestData.cs b/src/WixBuildTools.TestSupport/TestData.cs
new file mode 100644
index 0000000..fde9db5
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/TestData.cs
@@ -0,0 +1,16 @@
+// 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 WixBuildTools.TestSupport
+{
+ using System;
+ using System.IO;
+
+ public class TestData
+ {
+ public static string Get(params string[] paths)
+ {
+ var localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetCallingAssembly().CodeBase).LocalPath);
+ return Path.Combine(localPath, Path.Combine(paths));
+ }
+ }
+}
diff --git a/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj
new file mode 100644
index 0000000..e43a775
--- /dev/null
+++ b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj
@@ -0,0 +1,21 @@
+
+
+
+
+
+ netstandard2.0
+
+
+
+ NU1701
+
+
+
+
+
+
+
+
+
+
+