From ae4c3947277a5c05368276c31bc2cd562d7580bb Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 3 Mar 2025 22:19:36 -0500 Subject: Only referenced components get default feature. Fixes https://github.com/wixtoolset/issues/issues/8882 Fixes https://github.com/wixtoolset/issues/issues/8939 --- src/api/wix/WixToolset.Data/WixStandardLibrary.cs | 14 -------------- .../WixToolset.Data/WixStandardLibraryIdentifiers.cs | 5 ----- src/setup/ThmViewerPackage/ThmViewerPackage.wxs | 20 +++++--------------- .../WixToolset.Core/AssignDefaultFeatureCommand.cs | 19 +++++++++++-------- src/wix/WixToolset.Core/Linker.cs | 14 +++++++------- .../WixToolsetTest.CoreIntegration/FeatureFixture.cs | 11 +++++++++++ .../TestData/Feature/PackageDefaultFeature.wxs | 6 ++++++ .../TestData/ForEach/Package.wxs | 18 +++--------------- 8 files changed, 43 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/api/wix/WixToolset.Data/WixStandardLibrary.cs b/src/api/wix/WixToolset.Data/WixStandardLibrary.cs index dc7c5a8b..2d2a12fb 100644 --- a/src/api/wix/WixToolset.Data/WixStandardLibrary.cs +++ b/src/api/wix/WixToolset.Data/WixStandardLibrary.cs @@ -93,20 +93,6 @@ namespace WixToolset.Data yield return section; } - // Default feature. - { - var symbol = new FeatureSymbol(sourceLineNumber, new Identifier(AccessModifier.Virtual, WixStandardLibraryIdentifiers.DefaultFeatureName)) - { - Level = 1, - Display = 0, - InstallDefault = FeatureInstallDefault.Local, - }; - - var section = CreateSectionAroundSymbol(symbol); - - yield return section; - } - // Package References. { var section = CreateSection(WixStandardLibraryIdentifiers.WixStandardPackageReferences); diff --git a/src/api/wix/WixToolset.Data/WixStandardLibraryIdentifiers.cs b/src/api/wix/WixToolset.Data/WixStandardLibraryIdentifiers.cs index 73e4245b..a7ca11fe 100644 --- a/src/api/wix/WixToolset.Data/WixStandardLibraryIdentifiers.cs +++ b/src/api/wix/WixToolset.Data/WixStandardLibraryIdentifiers.cs @@ -17,11 +17,6 @@ namespace WixToolset.Data /// public static readonly string WixStandardModuleReferences = "WixStandardModuleReferences"; - /// - /// Default feature name. - /// - public static readonly string DefaultFeatureName = "WixDefaultFeature"; - /// /// WiX Standard localization strings. /// diff --git a/src/setup/ThmViewerPackage/ThmViewerPackage.wxs b/src/setup/ThmViewerPackage/ThmViewerPackage.wxs index df398d0f..66bbe766 100644 --- a/src/setup/ThmViewerPackage/ThmViewerPackage.wxs +++ b/src/setup/ThmViewerPackage/ThmViewerPackage.wxs @@ -1,23 +1,13 @@  - - - - - + + + + + - - - - - - - - - - diff --git a/src/wix/WixToolset.Core/AssignDefaultFeatureCommand.cs b/src/wix/WixToolset.Core/AssignDefaultFeatureCommand.cs index 614af1eb..3d4001a3 100644 --- a/src/wix/WixToolset.Core/AssignDefaultFeatureCommand.cs +++ b/src/wix/WixToolset.Core/AssignDefaultFeatureCommand.cs @@ -10,20 +10,22 @@ namespace WixToolset.Core internal class AssignDefaultFeatureCommand { - public AssignDefaultFeatureCommand(FindEntrySectionAndLoadSymbolsCommand find, List sections) + private static readonly string DefaultFeatureName = "WixDefaultFeature"; + + public AssignDefaultFeatureCommand(FindEntrySectionAndLoadSymbolsCommand find, ISet sections) { this.Find = find; this.Sections = sections; } - public IEnumerable Sections { get; } + public ISet Sections { get; } public FindEntrySectionAndLoadSymbolsCommand Find { get; } public void Execute() { if (this.Find.EntrySection.Type == SectionType.Package - && !this.Sections.Where(s => s.Id != WixStandardLibraryIdentifiers.DefaultFeatureName) + && !this.Sections.Where(s => s.Id != DefaultFeatureName) .SelectMany(s => s.Symbols).OfType().Any()) { var addedToDefaultFeature = false; @@ -35,7 +37,7 @@ namespace WixToolset.Core { this.Find.EntrySection.AddSymbol(new WixComplexReferenceSymbol(component.SourceLineNumbers) { - Parent = WixStandardLibraryIdentifiers.DefaultFeatureName, + Parent = DefaultFeatureName, ParentType = ComplexReferenceParentType.Feature, ParentLanguage = null, Child = component.Id.Id, @@ -45,7 +47,7 @@ namespace WixToolset.Core this.Find.EntrySection.AddSymbol(new WixGroupSymbol(component.SourceLineNumbers) { - ParentId = WixStandardLibraryIdentifiers.DefaultFeatureName, + ParentId = DefaultFeatureName, ParentType = ComplexReferenceParentType.Feature, ChildId = component.Id.Id, ChildType = ComplexReferenceChildType.Component, @@ -57,10 +59,11 @@ namespace WixToolset.Core if (addedToDefaultFeature) { - this.Find.EntrySection.AddSymbol(new WixSimpleReferenceSymbol() + this.Find.EntrySection.AddSymbol(new FeatureSymbol(null, new Identifier(AccessModifier.Virtual, DefaultFeatureName)) { - Table = "Feature", - PrimaryKeys = WixStandardLibraryIdentifiers.DefaultFeatureName, + Level = 1, + Display = 0, + InstallDefault = FeatureInstallDefault.Local, }); } } diff --git a/src/wix/WixToolset.Core/Linker.cs b/src/wix/WixToolset.Core/Linker.cs index b10a12d8..d2e09b59 100644 --- a/src/wix/WixToolset.Core/Linker.cs +++ b/src/wix/WixToolset.Core/Linker.cs @@ -138,13 +138,6 @@ namespace WixToolset.Core command.Execute(); } - // If there are no authored features, create a default feature and assign - // the components to it. - { - var command = new AssignDefaultFeatureCommand(find, sections); - command.Execute(); - } - // Resolve the symbol references to find the set of sections we care about for linking. // Of course, we start with the entry section (that's how it got its name after all). var resolve = new ResolveReferencesCommand(this.Messaging, find.EntrySection, find.SymbolsByName); @@ -155,6 +148,13 @@ namespace WixToolset.Core return null; } + // If there are no authored features, create a default feature and assign + // the components to it. + { + var command = new AssignDefaultFeatureCommand(find, resolve.ResolvedSections); + command.Execute(); + } + // Reset the sections to only those that were resolved then flatten the complex // references that particpate in groups. sections = resolve.ResolvedSections.ToList(); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs index 00fea67e..f8fb41a2 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs @@ -66,6 +66,17 @@ namespace WixToolsetTest.CoreIntegration Assert.Empty(result.Messages); Assert.True(File.Exists(msiPath)); + + result = WixRunner.Execute(new[] + { + "msi", + "validate", + "-intermediateFolder", intermediateFolder, + msiPath + }); + + Assert.Empty(result.Messages); + var results = Query.QueryDatabase(msiPath, new[] { "Feature", "FeatureComponents", "Shortcut" }); WixAssert.CompareLineByLine(new[] { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs index bd93e53c..da214e19 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs @@ -47,4 +47,10 @@ + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs index 8fff563e..26eaaf19 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs @@ -1,19 +1,7 @@ - - - - - - - - - + + + - - - - - - -- cgit v1.2.3-55-g6feb