-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See WIP at wixtoolset/issues#7581.
- Loading branch information
Showing
7 changed files
with
239 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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. | ||
|
||
namespace WixToolset.Core | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using WixToolset.Core.Link; | ||
using WixToolset.Data; | ||
using WixToolset.Data.Symbols; | ||
using WixToolset.Extensibility.Services; | ||
using static System.Collections.Specialized.BitVector32; | ||
|
||
internal class AssignDefaultFeatureCommand | ||
{ | ||
private const string DefaultFeatureName = "WixDefaultFeature"; | ||
|
||
public AssignDefaultFeatureCommand(IMessaging messaging, IntermediateSection entrySection, IEnumerable<IntermediateSection> sections, HashSet<string> referencedComponents, Link.ConnectToFeatureCollection componentsToFeatures) | ||
{ | ||
this.Messaging = messaging; | ||
this.EntrySection = entrySection; | ||
this.Sections = sections; | ||
this.ReferencedComponents = referencedComponents; | ||
this.ComponentsToFeatures = componentsToFeatures; | ||
} | ||
|
||
public IMessaging Messaging { get; } | ||
|
||
public IntermediateSection EntrySection { get; } | ||
|
||
public IEnumerable<IntermediateSection> Sections { get; } | ||
|
||
public HashSet<string> ReferencedComponents { get; } | ||
|
||
public ConnectToFeatureCollection ComponentsToFeatures { get; } | ||
|
||
public void Execute() | ||
{ | ||
var assignedComponents = false; | ||
|
||
foreach (var section in this.Sections) | ||
{ | ||
foreach (var component in section.Symbols.OfType<ComponentSymbol>().ToList()) | ||
{ | ||
if (!this.ReferencedComponents.Contains(component.Id.Id)) | ||
{ | ||
assignedComponents = true; | ||
|
||
this.ComponentsToFeatures.Add(new ConnectToFeature(section, component.Id.Id, DefaultFeatureName, explicitPrimaryFeature: true)); | ||
|
||
section.AddSymbol(new FeatureComponentsSymbol | ||
{ | ||
FeatureRef = DefaultFeatureName, | ||
ComponentRef = component.Id.Id, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
if (assignedComponents) | ||
{ | ||
this.EntrySection.AddSymbol(new FeatureSymbol(null, new Identifier(AccessModifier.Global, DefaultFeatureName)) | ||
{ | ||
Level = 1, | ||
Display = 0, | ||
InstallDefault = FeatureInstallDefault.Local, | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageBadDefaultFeature.wxs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
<Package Name="PackageMissingFeatureComponentMapping" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="12E4699F-E774-4D05-8A01-5BDD41BBA127"> | ||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | ||
|
||
<StandardDirectory Id="ProgramFiles6432Folder"> | ||
<Directory Id="INSTALLFOLDER" Name="PackageMissingFeatureComponentMapping"> | ||
<Directory Id="SubFolder" Name="NotMapped"> | ||
<Component> | ||
<File Source="test.txt" /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</StandardDirectory> | ||
|
||
<Feature Id="MissingComponentFeature" /> | ||
|
||
<Component Directory="INSTALLFOLDER"> | ||
<File Source="test.txt" /> | ||
</Component> | ||
|
||
<ComponentGroup Id="ImplicitFeatureComponentGroup" Directory="INSTALLFOLDER"> | ||
<Component> | ||
<File Name="test2.txt" Source="test.txt" /> | ||
</Component> | ||
</ComponentGroup> | ||
</Package> | ||
</Wix> |
46 changes: 46 additions & 0 deletions
46
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Feature/PackageDefaultFeature.wxs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
<Package Name="PackageMissingFeatureComponentMapping" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="12E4699F-E774-4D05-8A01-5BDD41BBA127"> | ||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | ||
|
||
<StandardDirectory Id="ProgramFiles6432Folder"> | ||
<Directory Id="INSTALLFOLDER" Name="PackageMissingFeatureComponentMapping"> | ||
<Directory Id="SubFolder" Name="NotMapped"> | ||
<Component> | ||
<File Source="test.txt" /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</StandardDirectory> | ||
|
||
<Component Directory="INSTALLFOLDER"> | ||
<File Source="test.txt" /> | ||
</Component> | ||
|
||
<ComponentRef Id="ComponentInAFragment" /> | ||
<ComponentGroupRef Id="ComponentGroupInAFragment" /> | ||
<FeatureGroupRef Id="FeatureGroupInAFragment" /> | ||
</Package> | ||
|
||
<Fragment> | ||
<ComponentGroup Id="ComponentGroupInAFragment" Directory="INSTALLFOLDER"> | ||
<Component> | ||
<File Name="test2.txt" Source="test.txt" /> | ||
</Component> | ||
</ComponentGroup> | ||
</Fragment> | ||
|
||
<Fragment> | ||
<FeatureGroup Id="FeatureGroupInAFragment" /> | ||
|
||
<Component Id="AnotherComponentInAFragment" Directory="INSTALLFOLDER"> | ||
<File Name="test3.txt" Source="test.txt" /> | ||
<Shortcut Id="AdvertisedShortcut" Advertise="yes" Name="Shortcut" /> | ||
</Component> | ||
</Fragment> | ||
|
||
<Fragment> | ||
<Component Id="ComponentInAFragment" Directory="INSTALLFOLDER"> | ||
<File Name="test4.txt" Source="test.txt" /> | ||
</Component> | ||
</Fragment> | ||
</Wix> |