diff options
| author | Rob Mensching <rob@firegiant.com> | 2023-04-18 09:02:59 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2023-04-18 11:47:25 -0700 |
| commit | 3b617d74241cb54fcbb85989538a681f7134349b (patch) | |
| tree | 7c917a83c9db2afae83ef82cdc632e79edf72f2a /src | |
| parent | 45f6dcfcdc4e5ed9350733825d8bcc5ed74f24ba (diff) | |
| download | wix-3b617d74241cb54fcbb85989538a681f7134349b.tar.gz wix-3b617d74241cb54fcbb85989538a681f7134349b.tar.bz2 wix-3b617d74241cb54fcbb85989538a681f7134349b.zip | |
Do not crash on Subdirectory when missing Component Directory attribute
Fixes 7407
Diffstat (limited to 'src')
3 files changed, 41 insertions, 3 deletions
diff --git a/src/wix/WixToolset.Core/Compiler.cs b/src/wix/WixToolset.Core/Compiler.cs index babde97d..70e246a5 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs | |||
| @@ -2254,8 +2254,7 @@ namespace WixToolset.Core | |||
| 2254 | { | 2254 | { |
| 2255 | this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Directory")); | 2255 | this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Directory")); |
| 2256 | } | 2256 | } |
| 2257 | 2257 | else if (!String.IsNullOrEmpty(subdirectory)) | |
| 2258 | if (!String.IsNullOrEmpty(subdirectory)) | ||
| 2259 | { | 2258 | { |
| 2260 | directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, directoryId, subdirectory); | 2259 | directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, directoryId, subdirectory); |
| 2261 | } | 2260 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ComponentFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ComponentFixture.cs index 94900ee0..9348afa5 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/ComponentFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ComponentFixture.cs | |||
| @@ -34,12 +34,41 @@ namespace WixToolsetTest.CoreIntegration | |||
| 34 | }); | 34 | }); |
| 35 | 35 | ||
| 36 | var errors = result.Messages.Where(m => m.Level == MessageLevel.Error); | 36 | var errors = result.Messages.Where(m => m.Level == MessageLevel.Error); |
| 37 | Array.Equals(new[] | 37 | Assert.Equal(new[] |
| 38 | { | 38 | { |
| 39 | 369, | 39 | 369, |
| 40 | 369 | 40 | 369 |
| 41 | }, errors.Select(e => e.Id).ToArray()); | 41 | }, errors.Select(e => e.Id).ToArray()); |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | |||
| 45 | [Fact] | ||
| 46 | public void CannotBuildMissingDirectoryAttributeWithSubdirectory() | ||
| 47 | { | ||
| 48 | var folder = TestData.Get(@"TestData"); | ||
| 49 | |||
| 50 | using (var fs = new DisposableFileSystem()) | ||
| 51 | { | ||
| 52 | var baseFolder = fs.GetFolder(); | ||
| 53 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 54 | var msiPath = Path.Combine(baseFolder, "bin", "test.msi"); | ||
| 55 | |||
| 56 | var result = WixRunner.Execute(new[] | ||
| 57 | { | ||
| 58 | "build", | ||
| 59 | Path.Combine(folder, "Component", "MissingDirectoryWithSubdirectory.wxs"), | ||
| 60 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 61 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
| 62 | "-intermediateFolder", intermediateFolder, | ||
| 63 | "-o", msiPath | ||
| 64 | }); | ||
| 65 | |||
| 66 | var errors = result.Messages.Select(m => m.ToString()).ToArray(); | ||
| 67 | WixAssert.CompareLineByLine(new[] | ||
| 68 | { | ||
| 69 | "The Component/@Directory attribute was not found; it is required." | ||
| 70 | }, errors); | ||
| 71 | } | ||
| 72 | } | ||
| 44 | } | 73 | } |
| 45 | } | 74 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Component/MissingDirectoryWithSubdirectory.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Component/MissingDirectoryWithSubdirectory.wxs new file mode 100644 index 00000000..cefa9abc --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Component/MissingDirectoryWithSubdirectory.wxs | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 3 | <Fragment> | ||
| 4 | <ComponentGroup Id="ProductComponents"> | ||
| 5 | <Component Subdirectory="fails\without\Directory\attribute"> | ||
| 6 | <File Source="test.txt" /> | ||
| 7 | </Component> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | </Wix> | ||
