summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2025-03-03 22:19:36 -0500
committerBob Arnson <github@bobs.org>2025-03-03 23:06:48 -0500
commitae4c3947277a5c05368276c31bc2cd562d7580bb (patch)
tree0e26edad956f07cf702d46030a3dec3022ba0748
parent29f885377442fa93f574f2b4430cb621c1ad809e (diff)
downloadwix-6.0.0-rc.2.tar.gz
wix-6.0.0-rc.2.tar.bz2
wix-6.0.0-rc.2.zip
Only referenced components get default feature.v6.0.0-rc.2
Fixes https://github.com/wixtoolset/issues/issues/8882 Fixes https://github.com/wixtoolset/issues/issues/8939
-rw-r--r--src/api/wix/WixToolset.Data/WixStandardLibrary.cs14
-rw-r--r--src/api/wix/WixToolset.Data/WixStandardLibraryIdentifiers.cs5
-rw-r--r--src/setup/ThmViewerPackage/ThmViewerPackage.wxs20
-rw-r--r--src/wix/WixToolset.Core/AssignDefaultFeatureCommand.cs19
-rw-r--r--src/wix/WixToolset.Core/Linker.cs14
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs11
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs6
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs18
8 files changed, 43 insertions, 64 deletions
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
93 yield return section; 93 yield return section;
94 } 94 }
95 95
96 // Default feature.
97 {
98 var symbol = new FeatureSymbol(sourceLineNumber, new Identifier(AccessModifier.Virtual, WixStandardLibraryIdentifiers.DefaultFeatureName))
99 {
100 Level = 1,
101 Display = 0,
102 InstallDefault = FeatureInstallDefault.Local,
103 };
104
105 var section = CreateSectionAroundSymbol(symbol);
106
107 yield return section;
108 }
109
110 // Package References. 96 // Package References.
111 { 97 {
112 var section = CreateSection(WixStandardLibraryIdentifiers.WixStandardPackageReferences); 98 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
@@ -18,11 +18,6 @@ namespace WixToolset.Data
18 public static readonly string WixStandardModuleReferences = "WixStandardModuleReferences"; 18 public static readonly string WixStandardModuleReferences = "WixStandardModuleReferences";
19 19
20 /// <summary> 20 /// <summary>
21 /// Default feature name.
22 /// </summary>
23 public static readonly string DefaultFeatureName = "WixDefaultFeature";
24
25 /// <summary>
26 /// WiX Standard localization strings. 21 /// WiX Standard localization strings.
27 /// </summary> 22 /// </summary>
28 public static readonly string WixStandardLocalizationStrings = "WixStandardLocalizationStrings"; 23 public static readonly string WixStandardLocalizationStrings = "WixStandardLocalizationStrings";
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,24 +1,14 @@
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. --> 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<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Package Id="WixToolset.ThemeViewer.Package" Name="WiX Toolset Theme Viewer" Manufacturer="WiX Toolset" Language="1033" Version="!(bind.fileVersion.ThmViewerFile)"> 3 <Package Id="WixToolset.ThemeViewer.Package" Name="WiX Toolset Theme Viewer" Manufacturer="WiX Toolset" Language="1033" Version="!(bind.fileVersion.ThmViewerFile)">
4 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 4 <Component>
5 5 <File Id="ThmViewerFile" Source="thmviewer.exe" />
6 <Feature Id="Main"> 6 <Shortcut Name="!(bind.property.ProductName)" Directory="ShortcutFolder" Advertise="yes" />
7 <ComponentGroupRef Id="Components" /> 7 <RemoveFolder Directory="ShortcutFolder" On="uninstall" />
8 </Feature> 8 </Component>
9 </Package> 9 </Package>
10 10
11 <Fragment> 11 <Fragment>
12 <ComponentGroup Id="Components" Directory="INSTALLFOLDER" Subdirectory="bin">
13 <Component>
14 <File Id="ThmViewerFile" Source="thmviewer.exe" />
15 <Shortcut Name="!(bind.property.ProductName)" Directory="ShortcutFolder" Advertise="yes" />
16 <RemoveFolder Directory="ShortcutFolder" On="uninstall" />
17 </Component>
18 </ComponentGroup>
19 </Fragment>
20
21 <Fragment>
22 <StandardDirectory Id="ProgramFilesFolder"> 12 <StandardDirectory Id="ProgramFilesFolder">
23 <Directory Id="INSTALLFOLDER" Name="WiX Toolset v$(SetupMajorMinorVersion)" /> 13 <Directory Id="INSTALLFOLDER" Name="WiX Toolset v$(SetupMajorMinorVersion)" />
24 </StandardDirectory> 14 </StandardDirectory>
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
10 10
11 internal class AssignDefaultFeatureCommand 11 internal class AssignDefaultFeatureCommand
12 { 12 {
13 public AssignDefaultFeatureCommand(FindEntrySectionAndLoadSymbolsCommand find, List<IntermediateSection> sections) 13 private static readonly string DefaultFeatureName = "WixDefaultFeature";
14
15 public AssignDefaultFeatureCommand(FindEntrySectionAndLoadSymbolsCommand find, ISet<IntermediateSection> sections)
14 { 16 {
15 this.Find = find; 17 this.Find = find;
16 this.Sections = sections; 18 this.Sections = sections;
17 } 19 }
18 20
19 public IEnumerable<IntermediateSection> Sections { get; } 21 public ISet<IntermediateSection> Sections { get; }
20 22
21 public FindEntrySectionAndLoadSymbolsCommand Find { get; } 23 public FindEntrySectionAndLoadSymbolsCommand Find { get; }
22 24
23 public void Execute() 25 public void Execute()
24 { 26 {
25 if (this.Find.EntrySection.Type == SectionType.Package 27 if (this.Find.EntrySection.Type == SectionType.Package
26 && !this.Sections.Where(s => s.Id != WixStandardLibraryIdentifiers.DefaultFeatureName) 28 && !this.Sections.Where(s => s.Id != DefaultFeatureName)
27 .SelectMany(s => s.Symbols).OfType<FeatureSymbol>().Any()) 29 .SelectMany(s => s.Symbols).OfType<FeatureSymbol>().Any())
28 { 30 {
29 var addedToDefaultFeature = false; 31 var addedToDefaultFeature = false;
@@ -35,7 +37,7 @@ namespace WixToolset.Core
35 { 37 {
36 this.Find.EntrySection.AddSymbol(new WixComplexReferenceSymbol(component.SourceLineNumbers) 38 this.Find.EntrySection.AddSymbol(new WixComplexReferenceSymbol(component.SourceLineNumbers)
37 { 39 {
38 Parent = WixStandardLibraryIdentifiers.DefaultFeatureName, 40 Parent = DefaultFeatureName,
39 ParentType = ComplexReferenceParentType.Feature, 41 ParentType = ComplexReferenceParentType.Feature,
40 ParentLanguage = null, 42 ParentLanguage = null,
41 Child = component.Id.Id, 43 Child = component.Id.Id,
@@ -45,7 +47,7 @@ namespace WixToolset.Core
45 47
46 this.Find.EntrySection.AddSymbol(new WixGroupSymbol(component.SourceLineNumbers) 48 this.Find.EntrySection.AddSymbol(new WixGroupSymbol(component.SourceLineNumbers)
47 { 49 {
48 ParentId = WixStandardLibraryIdentifiers.DefaultFeatureName, 50 ParentId = DefaultFeatureName,
49 ParentType = ComplexReferenceParentType.Feature, 51 ParentType = ComplexReferenceParentType.Feature,
50 ChildId = component.Id.Id, 52 ChildId = component.Id.Id,
51 ChildType = ComplexReferenceChildType.Component, 53 ChildType = ComplexReferenceChildType.Component,
@@ -57,10 +59,11 @@ namespace WixToolset.Core
57 59
58 if (addedToDefaultFeature) 60 if (addedToDefaultFeature)
59 { 61 {
60 this.Find.EntrySection.AddSymbol(new WixSimpleReferenceSymbol() 62 this.Find.EntrySection.AddSymbol(new FeatureSymbol(null, new Identifier(AccessModifier.Virtual, DefaultFeatureName))
61 { 63 {
62 Table = "Feature", 64 Level = 1,
63 PrimaryKeys = WixStandardLibraryIdentifiers.DefaultFeatureName, 65 Display = 0,
66 InstallDefault = FeatureInstallDefault.Local,
64 }); 67 });
65 } 68 }
66 } 69 }
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
138 command.Execute(); 138 command.Execute();
139 } 139 }
140 140
141 // If there are no authored features, create a default feature and assign
142 // the components to it.
143 {
144 var command = new AssignDefaultFeatureCommand(find, sections);
145 command.Execute();
146 }
147
148 // Resolve the symbol references to find the set of sections we care about for linking. 141 // Resolve the symbol references to find the set of sections we care about for linking.
149 // Of course, we start with the entry section (that's how it got its name after all). 142 // Of course, we start with the entry section (that's how it got its name after all).
150 var resolve = new ResolveReferencesCommand(this.Messaging, find.EntrySection, find.SymbolsByName); 143 var resolve = new ResolveReferencesCommand(this.Messaging, find.EntrySection, find.SymbolsByName);
@@ -155,6 +148,13 @@ namespace WixToolset.Core
155 return null; 148 return null;
156 } 149 }
157 150
151 // If there are no authored features, create a default feature and assign
152 // the components to it.
153 {
154 var command = new AssignDefaultFeatureCommand(find, resolve.ResolvedSections);
155 command.Execute();
156 }
157
158 // Reset the sections to only those that were resolved then flatten the complex 158 // Reset the sections to only those that were resolved then flatten the complex
159 // references that particpate in groups. 159 // references that particpate in groups.
160 sections = resolve.ResolvedSections.ToList(); 160 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
66 Assert.Empty(result.Messages); 66 Assert.Empty(result.Messages);
67 67
68 Assert.True(File.Exists(msiPath)); 68 Assert.True(File.Exists(msiPath));
69
70 result = WixRunner.Execute(new[]
71 {
72 "msi",
73 "validate",
74 "-intermediateFolder", intermediateFolder,
75 msiPath
76 });
77
78 Assert.Empty(result.Messages);
79
69 var results = Query.QueryDatabase(msiPath, new[] { "Feature", "FeatureComponents", "Shortcut" }); 80 var results = Query.QueryDatabase(msiPath, new[] { "Feature", "FeatureComponents", "Shortcut" });
70 WixAssert.CompareLineByLine(new[] 81 WixAssert.CompareLineByLine(new[]
71 { 82 {
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 @@
47 <File Name="test4.txt" Source="test.txt" /> 47 <File Name="test4.txt" Source="test.txt" />
48 </Component> 48 </Component>
49 </Fragment> 49 </Fragment>
50
51 <Fragment>
52 <Component Id="UnreferencedComponentInAFragment" Directory="INSTALLFOLDER">
53 <File Name="test5.txt" Source="test.txt" />
54 </Component>
55 </Fragment>
50</Wix> 56</Wix>
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 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="MsiPackage" Language="1033" Version="1.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" Compressed="no" InstallerVersion="200" Scope="perMachine"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" Compressed="no" InstallerVersion="200" Scope="perMachine">
3 3 <ComponentGroupRef Id="ProductComponents.x86" />
4 4 <ComponentGroupRef Id="ProductComponents.x64" />
5 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> 5 <ComponentGroupRef Id="ProductComponents.arm" />
6
7 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
8 <ComponentGroupRef Id="ProductComponents.x86" />
9 <ComponentGroupRef Id="ProductComponents.x64" />
10 <ComponentGroupRef Id="ProductComponents.arm" />
11 </Feature>
12 </Package> 6 </Package>
13
14 <Fragment>
15 <StandardDirectory Id="ProgramFilesFolder">
16 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
17 </StandardDirectory>
18 </Fragment>
19</Wix> 7</Wix>