From bc101e0424d627ca79f79b30e9fccf61db722466 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 23 Feb 2022 15:15:10 -0800 Subject: Fix wixlib, msm, msi incremental build Simplify and improves the tracking of input and intermediate files to fix incremental build issues for wixlibs, merge modules and MSI databases. --- .../WixprojModuleCsprojWinFormsNetFx.wixproj | 10 +- .../Package.ja-jp.wxl | 2 +- .../WixprojPackageVcxprojWindowsApp/Package.wxs | 6 +- .../WixprojPackageVcxprojWindowsApp.wixproj | 2 + src/test/wix/WixE2E/WixE2EFixture.cs | 109 +++++++++++++++++++++ 5 files changed, 118 insertions(+), 11 deletions(-) (limited to 'src/test') diff --git a/src/test/wix/TestData/WixprojModuleCsprojWinFormsNetFx/WixprojModuleCsprojWinFormsNetFx.wixproj b/src/test/wix/TestData/WixprojModuleCsprojWinFormsNetFx/WixprojModuleCsprojWinFormsNetFx.wixproj index 07e42b08..6009460c 100644 --- a/src/test/wix/TestData/WixprojModuleCsprojWinFormsNetFx/WixprojModuleCsprojWinFormsNetFx.wixproj +++ b/src/test/wix/TestData/WixprojModuleCsprojWinFormsNetFx/WixprojModuleCsprojWinFormsNetFx.wixproj @@ -1,19 +1,11 @@ + - Module - - - - diff --git a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.ja-jp.wxl b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.ja-jp.wxl index 52e1871e..0f902c8d 100644 --- a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.ja-jp.wxl +++ b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.ja-jp.wxl @@ -5,7 +5,7 @@ This file contains the declaration of all the localizable strings. --> - WixprojPackageVcxprojWindowsApp, eh? + WixprojPackageVcxprojWindowsApp-jp The First Feature in my Prooooduct, eh? diff --git a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.wxs b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.wxs index fe849608..508d4721 100644 --- a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.wxs +++ b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/Package.wxs @@ -1,5 +1,7 @@ - + + @@ -16,5 +18,7 @@ + + diff --git a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj index 7dc26a2d..bbd39870 100644 --- a/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj +++ b/src/test/wix/TestData/WixprojPackageVcxprojWindowsApp/WixprojPackageVcxprojWindowsApp.wixproj @@ -5,5 +5,7 @@ + + diff --git a/src/test/wix/WixE2E/WixE2EFixture.cs b/src/test/wix/WixE2E/WixE2EFixture.cs index 89762f72..b1c6b2de 100644 --- a/src/test/wix/WixE2E/WixE2EFixture.cs +++ b/src/test/wix/WixE2E/WixE2EFixture.cs @@ -2,7 +2,12 @@ namespace WixE2E { + using System; using System.IO; + using System.Linq; + using System.Security.Cryptography; + using System.Text; + using System.Threading; using WixBuildTools.TestSupport; using Xunit; @@ -52,6 +57,93 @@ namespace WixE2E result.AssertSuccess(); } + [Fact] + public void CanIncrementalBuildPackageWithNativeWindowsAppWithNoEdits() + { + var projectDirectory = TestData.Get("TestData", "WixprojPackageVcxprojWindowsApp"); + var projectPath = Path.Combine(projectDirectory, "WixprojPackageVcxprojWindowsApp.wixproj"); + var projectBinPath = Path.Combine(projectDirectory, "bin"); + + CleanEverything(); + + var result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var firstBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var firstHashes = firstBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + // This should be an incremental build and not do any work. + // + result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var secondBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var secondHashes = secondBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + WixAssert.CompareLineByLine(firstHashes, secondHashes); + } + + [Fact] + public void CanIncrementalBuildPackageWithNativeWindowsAppWithEdits() + { + var projectDirectory = TestData.Get("TestData", "WixprojPackageVcxprojWindowsApp"); + var projectPath = Path.Combine(projectDirectory, "WixprojPackageVcxprojWindowsApp.wixproj"); + var projectBinPath = Path.Combine(projectDirectory, "bin"); + + CleanEverything(); + + var result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var firstBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var firstRelativePaths = firstBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')}").ToArray(); + var firstHashes = firstBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + var packageWxsPath = Path.Combine(projectDirectory, "Package.wxs"); + File.SetLastWriteTime(packageWxsPath, DateTime.Now); + + // This should be an incremental build that does work because a file was updated. + // + result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var secondBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var secondRelativePaths = secondBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')}").ToArray(); + var secondHashes = secondBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + WixAssert.CompareLineByLine(firstRelativePaths, secondRelativePaths); + Assert.NotEqual(firstHashes, secondHashes); + } + + [Fact(Skip = "Investigate if .NET Core WebApplications can be incrementally built")] + public void CanIncrementalBuildPackageWithNetCoreWebAppWithoutEdits() + { + var projectDirectory = TestData.Get("TestData", "WixprojPackageCsprojWebApplicationNetCore"); + var projectPath = Path.Combine(projectDirectory, "WixprojPackageCsprojWebApplicationNetCore.wixproj"); + var projectBinPath = Path.Combine(projectDirectory, "bin"); + + CleanEverything(); + + var result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var firstBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var firstHashes = firstBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + //var packageWxsPath = Path.Combine(projectDirectory, "Package.wxs"); + //File.SetLastWriteTime(packageWxsPath, DateTime.Now); + + // This should be an incremental build that does work because a file was updated. + // + result = RestoreAndBuild(projectPath); + result.AssertSuccess(); + + var secondBuiltFiles = Directory.GetFiles(projectBinPath, "*.*", SearchOption.AllDirectories).ToArray(); + var secondHashes = secondBuiltFiles.Select(s => $"{s.Substring(projectBinPath.Length).TrimStart('\\')} with hash: {GetFileHash(s)}").ToArray(); + + WixAssert.CompareLineByLine(firstHashes, secondHashes); + } + private static void CleanEverything() { var rootFolder = TestData.Get("TestData"); @@ -71,6 +163,23 @@ namespace WixE2E } } + private static string GetFileHash(string path) + { + using (var sha2 = SHA256.Create()) + { + var bytes = File.ReadAllBytes(path); + var hashBytes = sha2.ComputeHash(bytes); + + var sb = new StringBuilder(); + foreach (var hash in hashBytes) + { + sb.AppendFormat("{0:X}", hash); + } + + return sb.ToString(); + } + } + private static MsbuildRunnerResult RestoreAndBuild(string projectPath, bool x64 = true) { return MsbuildRunner.Execute(projectPath, new[] { "-Restore", "-v:m", "-bl" }, x64); -- cgit v1.2.3-55-g6feb