@joebigelow / wix-1 / commits / 8a4c0810

Improve file not found error message

Fixes 2805

Rob Mensching committed Nov 21, 2022 at 00:05 UTC 8a4c0810ea2756888df18b0da5813e8c5bad4c54
6 files changed +14 -14
src/api/wix/WixToolset.Data/ErrorMessages.cs
+6 -6
@@ -640,19 +640,19 @@ namespace WixToolset.Data
640
641 public static Message FileNotFound(SourceLineNumber sourceLineNumbers, string file)
642 {
643 - return Message(sourceLineNumbers, Ids.FileNotFound, "The system cannot find the file '{0}'.", file);
643 + return Message(sourceLineNumbers, Ids.FileNotFound, "Cannot find the file '{0}'.", file);
644 }
645
646 public static Message FileNotFound(SourceLineNumber sourceLineNumbers, string file, string fileType)
647 {
648 - return Message(sourceLineNumbers, Ids.FileNotFound, "The system cannot find the file '{0}' with type '{1}'.", file, fileType);
648 + return Message(sourceLineNumbers, Ids.FileNotFound, "Cannot find the {0} file '{1}'.", fileType, file);
649 }
650
651 public static Message FileNotFound(SourceLineNumber sourceLineNumbers, string file, string fileType, IEnumerable<string> checkedPaths)
652 {
653 var combinedCheckedPaths = String.Join(", ", checkedPaths);
654 - var withType = String.IsNullOrEmpty(fileType) ? String.Empty : $" with type '{fileType}'";
655 - return Message(sourceLineNumbers, Ids.FileNotFound, "The system cannot find the file '{0}'{1}. The following paths were checked: {2}", file, withType, combinedCheckedPaths);
654 + var fileTypePrefix = String.IsNullOrEmpty(fileType) ? String.Empty : fileType + " ";
655 + return Message(sourceLineNumbers, Ids.FileNotFound, "Cannot find the {0}file '{1}'. The following paths were checked: {2}", fileTypePrefix, file, combinedCheckedPaths);
656 }
657
658 public static Message FileOrDirectoryPathRequired(string parameter)
@@ -662,12 +662,12 @@ namespace WixToolset.Data
662
663 public static Message FilePathRequired(string filePurpose)
664 {
665 - return Message(null, Ids.FilePathRequired, "The path to {0} is required.", filePurpose);
665 + return Message(null, Ids.FilePathRequired, "The path to the {0} is required.", filePurpose);
666 }
667
668 public static Message FilePathRequired(string parameter, string filePurpose)
669 {
670 - return Message(null, Ids.FilePathRequired, "The parameter '{0}' must be followed by a file path for {1}.", parameter, filePurpose);
670 + return Message(null, Ids.FilePathRequired, "The parameter '{0}' must be followed by a file path for the {1}.", parameter, filePurpose);
671 }
672
673 public static Message FileTooLarge(SourceLineNumber sourceLineNumbers, string fileName)
src/wix/WixToolset.Core.Burn/Bundles/HarvestBundlePackageCommand.cs
+2 -2
@@ -281,7 +281,7 @@ namespace WixToolset.Core.Burn.Bundles
281 if (!payloadNames.Contains(containerFullName))
282 {
283 var generatedId = this.BackendHelper.GenerateIdentifier("hcp", this.PackagePayload.Id.Id, containerName);
284 - var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, containerName, "Container", this.PackagePayload.SourceLineNumbers);
284 + var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, containerName, "container", this.PackagePayload.SourceLineNumbers);
285
286 this.Payloads.Add(new WixBundlePayloadSymbol(this.PackagePayload.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
287 {
@@ -341,7 +341,7 @@ namespace WixToolset.Core.Burn.Bundles
341 if (!payloadNames.Contains(payloadFullName))
342 {
343 var generatedId = this.BackendHelper.GenerateIdentifier("hpp", this.PackagePayload.Id.Id, payloadName);
344 - var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, payloadName, "Payload", this.PackagePayload.SourceLineNumbers);
344 + var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, payloadName, "payload", this.PackagePayload.SourceLineNumbers);
345
346 this.Payloads.Add(new WixBundlePayloadSymbol(this.PackagePayload.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
347 {
src/wix/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs
+2 -2
@@ -452,7 +452,7 @@ namespace WixToolset.Core.Burn.Bundles
452 if (!payloadNames.Contains(cabinetName))
453 {
454 var generatedId = this.BackendHelper.GenerateIdentifier("cab", this.PackagePayload.Id.Id, cabinet);
455 - var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, cabinet, "Cabinet", sourceLineNumbers);
455 + var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, cabinet, "cabinet", sourceLineNumbers);
456
457 this.Section.AddSymbol(new WixBundlePayloadSymbol(sourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
458 {
@@ -516,7 +516,7 @@ namespace WixToolset.Core.Burn.Bundles
516 if (!payloadNames.Contains(name))
517 {
518 var generatedId = this.BackendHelper.GenerateIdentifier("f", this.PackagePayload.Id.Id, record.GetString(2));
519 - var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, fileSourcePath, "File", sourceLineNumbers);
519 + var payloadSourceFile = this.ResolveRelatedFile(this.PackagePayload.SourceFile.Path, this.PackagePayload.UnresolvedSourceFile, fileSourcePath, "payload", sourceLineNumbers);
520
521 this.Section.AddSymbol(new WixBundlePayloadSymbol(sourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
522 {
src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
+1 -1
@@ -697,7 +697,7 @@ namespace WixToolset.Core.CommandLine
697 }
698 else
699 {
700 - parser.GetArgumentAsFilePathOrError(arg, "input file", this.UnclassifiedInputFilePaths);
700 + parser.GetArgumentAsFilePathOrError(arg, "input", this.UnclassifiedInputFilePaths);
701 return true;
702 }
703 }
src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+2 -2
@@ -84,8 +84,8 @@ namespace WixToolsetTest.CoreIntegration
84 var errorMessages = messages.Select(m => m.ToString().Replace(folder, "<folder>")).ToArray();
85 WixAssert.CompareLineByLine(new[]
86 {
87 - @"The system cannot find the file 'test.txt' with type 'File'. The following paths were checked: test.txt, <folder>\does-not-exist\test.txt, <folder>\also-does-not-exist\test.txt",
88 - @"The system cannot find the file 'test.txt' with type 'File'. The following paths were checked: test.txt, <folder>\does-not-exist\test.txt, <folder>\also-does-not-exist\test.txt",
87 + @"Cannot find the File file 'test.txt'. The following paths were checked: test.txt, <folder>\does-not-exist\test.txt, <folder>\also-does-not-exist\test.txt",
88 + @"Cannot find the File file 'test.txt'. The following paths were checked: test.txt, <folder>\does-not-exist\test.txt, <folder>\also-does-not-exist\test.txt",
89 }, errorMessages);
90
91 var errorMessage = errorMessages.First();
src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+1 -1
@@ -391,7 +391,7 @@ namespace WixToolsetTest.CoreIntegration
391 var messages = result.Messages.Select(m => m.ToString().Replace(tempFolderPatch, "<tempFolderPatch>").Replace(templateBaselineFolder, "<templateBaselineFolder>").Replace(templateUpdateFolder, "<templateUpdateFolder>")).ToArray();
392 WixAssert.CompareLineByLine(new[]
393 {
394 - @"The system cannot find the file 'Missing.wixpdb' with type 'WixPatchBaseline'. The following paths were checked: Missing.wixpdb, <tempFolderPatch>\bin\Missing.wixpdb, <templateBaselineFolder>\Missing.wixpdb, <templateUpdateFolder>\Missing.wixpdb",
394 + @"Cannot find the WixPatchBaseline file 'Missing.wixpdb'. The following paths were checked: Missing.wixpdb, <tempFolderPatch>\bin\Missing.wixpdb, <templateBaselineFolder>\Missing.wixpdb, <templateUpdateFolder>\Missing.wixpdb",
395 }, messages);
396 }
397 }