Track database copy for validation as temporary
Rob Mensching committed
Mar 18, 2021 at 02:12 UTC
a451caf6d60e3f7fcbd56b87ca3c0f393e8f7b52
2 files changed
+17
-5
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+3
-1
@@ -537,8 +537,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
537
// Validate the output if there are CUBe files and we're not explicitly suppressing validation.
538
if (this.CubeFiles != null && !this.SuppressValidation)
539
{
540
- var command = new ValidateDatabaseCommand(this.Messaging, this.IntermediateFolder, data, this.OutputPath, this.CubeFiles, this.Ices, this.SuppressedIces);
540
+ var command = new ValidateDatabaseCommand(this.Messaging, this.WindowsInstallerBackendHelper, this.IntermediateFolder, data, this.OutputPath, this.CubeFiles, this.Ices, this.SuppressedIces);
541
command.Execute();
542
+
543
+ trackedFiles.AddRange(command.TrackedFiles);
544
}
545
546
if (this.Messaging.EncounteredError)
src/WixToolset.Core.WindowsInstaller/Bind/ValidateDatabaseCommand.cs
+14
-4
@@ -4,15 +4,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
4
{
5
using System;
6
using System.Collections.Generic;
7
- using System.ComponentModel;
7
using System.Diagnostics;
8
using System.IO;
9
using System.Linq;
11
- using System.Threading;
10
using WixToolset.Core.Native;
13
- using WixToolset.Core.Native.Msi;
11
using WixToolset.Data;
12
using WixToolset.Data.WindowsInstaller;
13
+ using WixToolset.Extensibility.Data;
14
using WixToolset.Extensibility.Services;
15
16
internal class ValidateDatabaseCommand : IWindowsInstallerValidatorCallback
@@ -20,9 +18,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
18
// Set of ICEs that have equivalent-or-better checks in WiX.
19
private static readonly string[] WellKnownSuppressedIces = new[] { "ICE08", "ICE33", "ICE47", "ICE66" };
20
23
- public ValidateDatabaseCommand(IMessaging messaging, string intermediateFolder, WindowsInstallerData data, string outputPath, IEnumerable<string> cubeFiles, IEnumerable<string> ices, IEnumerable<string> suppressedIces)
21
+ public ValidateDatabaseCommand(IMessaging messaging, IBackendHelper backendHelper, string intermediateFolder, WindowsInstallerData data, string outputPath, IEnumerable<string> cubeFiles, IEnumerable<string> ices, IEnumerable<string> suppressedIces)
22
{
23
this.Messaging = messaging;
24
+ this.BackendHelper = backendHelper;
25
this.Data = data;
26
this.OutputPath = outputPath;
27
this.CubeFiles = cubeFiles;
@@ -33,6 +32,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
32
this.OutputSourceLineNumber = new SourceLineNumber(outputPath);
33
}
34
35
+ public IEnumerable<ITrackedFile> TrackedFiles { get; private set; }
36
+
37
/// <summary>
38
/// Encountered error implementation for <see cref="IWindowsInstallerValidatorCallback"/>.
39
/// </summary>
@@ -40,6 +41,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
41
42
private IMessaging Messaging { get; }
43
44
+ private IBackendHelper BackendHelper { get; }
45
+
46
private WindowsInstallerData Data { get; }
47
48
private string OutputPath { get; }
@@ -61,6 +64,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
64
65
public void Execute()
66
{
67
+ var trackedFiles = new List<ITrackedFile>();
68
var stopwatch = Stopwatch.StartNew();
69
70
this.Messaging.Write(VerboseMessages.ValidatingDatabase());
@@ -74,6 +78,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
78
var workingDatabasePath = Path.Combine(workingFolder, Path.GetFileName(this.OutputPath));
79
FileSystem.CopyFile(this.OutputPath, workingDatabasePath, allowHardlink: false);
80
81
+ var trackWorkingDatabase = this.BackendHelper.TrackFile(workingDatabasePath, TrackedFileType.Temporary);
82
+ trackedFiles.Add(trackWorkingDatabase);
83
+
84
var attributes = File.GetAttributes(workingDatabasePath);
85
File.SetAttributes(workingDatabasePath, attributes & ~FileAttributes.ReadOnly);
86
@@ -82,6 +89,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
89
90
stopwatch.Stop();
91
this.Messaging.Write(VerboseMessages.ValidatedDatabase(stopwatch.ElapsedMilliseconds));
92
+
93
+
94
+ this.TrackedFiles = trackedFiles;
95
}
96
97
private void LogValidationMessage(ValidationMessage message)