diff options
author | Rob Mensching <rob@firegiant.com> | 2022-02-03 07:36:01 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-02-03 08:15:28 -0800 |
commit | 7d15b1bc97cdd9933ca43a6b16b84a81b22c3457 (patch) | |
tree | 321f2c0daf44a12add7adf56e9cf51cb44709773 | |
parent | 56521d6d938915bc27c86e99f56724fecc1ae1de (diff) | |
download | wix-7d15b1bc97cdd9933ca43a6b16b84a81b22c3457.tar.gz wix-7d15b1bc97cdd9933ca43a6b16b84a81b22c3457.tar.bz2 wix-7d15b1bc97cdd9933ca43a6b16b84a81b22c3457.zip |
Fix feature/component mapping verification
3 files changed, 69 insertions, 7 deletions
diff --git a/src/wix/WixToolset.Core/Linker.cs b/src/wix/WixToolset.Core/Linker.cs index 47671f26..1fb7d18c 100644 --- a/src/wix/WixToolset.Core/Linker.cs +++ b/src/wix/WixToolset.Core/Linker.cs | |||
@@ -156,11 +156,11 @@ namespace WixToolset.Core | |||
156 | } | 156 | } |
157 | 157 | ||
158 | // Display an error message for Components that were not referenced by a Feature. | 158 | // Display an error message for Components that were not referenced by a Feature. |
159 | foreach (var symbolWithSection in resolve.ReferencedSymbolWithSections.Where(s => s.Symbol.Definition.Type == SymbolDefinitionType.Component)) | 159 | foreach (var component in sections.SelectMany(s => s.Symbols.Where(y => y.Definition.Type == SymbolDefinitionType.Component))) |
160 | { | 160 | { |
161 | if (!referencedComponents.Contains(symbolWithSection.Name)) | 161 | if (!referencedComponents.Contains(component.Id.Id)) |
162 | { | 162 | { |
163 | this.Messaging.Write(ErrorMessages.OrphanedComponent(symbolWithSection.Symbol.SourceLineNumbers, symbolWithSection.Symbol.Id.Id)); | 163 | this.Messaging.Write(ErrorMessages.OrphanedComponent(component.SourceLineNumbers, component.Id.Id)); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
@@ -451,8 +451,7 @@ namespace WixToolset.Core | |||
451 | }); | 451 | }); |
452 | 452 | ||
453 | // index the component for finding orphaned records | 453 | // index the component for finding orphaned records |
454 | var symbolName = String.Concat("Component:", wixComplexReferenceRow.Child); | 454 | referencedComponents.Add(wixComplexReferenceRow.Child); |
455 | referencedComponents.Add(symbolName); | ||
456 | 455 | ||
457 | break; | 456 | break; |
458 | 457 | ||
@@ -521,8 +520,7 @@ namespace WixToolset.Core | |||
521 | } | 520 | } |
522 | 521 | ||
523 | // index the component for finding orphaned records | 522 | // index the component for finding orphaned records |
524 | var componentSymbolName = String.Concat("Component:", wixComplexReferenceRow.Child); | 523 | referencedComponents.Add(wixComplexReferenceRow.Child); |
525 | referencedComponents.Add(componentSymbolName); | ||
526 | 524 | ||
527 | break; | 525 | break; |
528 | 526 | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs new file mode 100644 index 00000000..f70db559 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs | |||
@@ -0,0 +1,43 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.CoreIntegration | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixBuildTools.TestSupport; | ||
9 | using WixToolset.Core.TestPackage; | ||
10 | using WixToolset.Data; | ||
11 | using Xunit; | ||
12 | |||
13 | public class FeatureFixture | ||
14 | { | ||
15 | [Fact] | ||
16 | public void CanDetectMissingFeatureComponentMapping() | ||
17 | { | ||
18 | var folder = TestData.Get(@"TestData"); | ||
19 | |||
20 | using (var fs = new DisposableFileSystem()) | ||
21 | { | ||
22 | var baseFolder = fs.GetFolder(); | ||
23 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
24 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
25 | |||
26 | var result = WixRunner.Execute(new[] | ||
27 | { | ||
28 | "build", | ||
29 | Path.Combine(folder, "Feature", "PackageMissingFeatureComponentMapping.wxs"), | ||
30 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
31 | "-intermediateFolder", intermediateFolder, | ||
32 | "-o", msiPath | ||
33 | }); | ||
34 | |||
35 | var errors = result.Messages.Where(m => m.Level == MessageLevel.Error); | ||
36 | Assert.Equal(new[] | ||
37 | { | ||
38 | 267 | ||
39 | }, errors.Select(e => e.Id).ToArray()); | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | } | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageMissingFeatureComponentMapping.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageMissingFeatureComponentMapping.wxs new file mode 100644 index 00000000..ea7a8a10 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageMissingFeatureComponentMapping.wxs | |||
@@ -0,0 +1,21 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Package Name="PackageMissingFeatureComponentMapping" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="12E4699F-E774-4D05-8A01-5BDD41BBA127"> | ||
3 | <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | ||
4 | |||
5 | <StandardDirectory Id="ProgramFiles6432Folder"> | ||
6 | <Directory Id="INSTALLFOLDER" Name="PackageMissingFeatureComponentMapping"> | ||
7 | <Directory Name="NotMapped"> | ||
8 | <Component> | ||
9 | <File Source="test.txt" /> | ||
10 | </Component> | ||
11 | </Directory> | ||
12 | </Directory> | ||
13 | </StandardDirectory> | ||
14 | |||
15 | <Feature Id="MissingComponentFeature" Title="Feature is Missing a ComponentRef"> | ||
16 | <Component Directory="INSTALLFOLDER"> | ||
17 | <File Source="test.txt" /> | ||
18 | </Component> | ||
19 | </Feature> | ||
20 | </Package> | ||
21 | </Wix> | ||