From d63a1df11f5a39b9ec0a3f1452b4f6a4f727bd13 Mon Sep 17 00:00:00 2001 From: Jozef Izso Date: Tue, 21 Aug 2018 21:45:06 +0200 Subject: [PATCH] Display more specific error message when UpdateFileRow cannot access a file --- src/tools/wix/Binder.cs | 17 ++++++++++++----- src/tools/wix/Data/messages.xml | 7 +++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/tools/wix/Binder.cs b/src/tools/wix/Binder.cs index fdd0aec0f..dcdfd135c 100644 --- a/src/tools/wix/Binder.cs +++ b/src/tools/wix/Binder.cs @@ -6274,14 +6274,21 @@ private void UpdateFileRow(Output output, IDictionary infoCache, string version; string language; - using (FileStream fileStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read)) + try { - if (Int32.MaxValue < fileStream.Length) + using (FileStream fileStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read)) { - throw new WixException(WixErrors.FileTooLarge(fileRow.SourceLineNumbers, fileRow.Source)); - } + if (Int32.MaxValue < fileStream.Length) + { + throw new WixException(WixErrors.FileTooLarge(fileRow.SourceLineNumbers, fileRow.Source)); + } - fileRow.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); + fileRow.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); + } + } + catch (IOException e) + { + throw new WixException(WixErrors.BinderIOException(fileRow.SourceLineNumbers, fileInfo.FullName, e.Message)); } try diff --git a/src/tools/wix/Data/messages.xml b/src/tools/wix/Data/messages.xml index 14d4ab4ac..e0645adfc 100644 --- a/src/tools/wix/Data/messages.xml +++ b/src/tools/wix/Data/messages.xml @@ -4012,5 +4012,12 @@ + + + The file '{0}' cannot be accessed. Exception: {1} + + + +