1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// 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;
internal class AssignDefaultFeatureCommand
{
private static readonly string DefaultFeatureName = "WixDefaultFeature";
public AssignDefaultFeatureCommand(FindEntrySectionAndLoadSymbolsCommand find, ISet<IntermediateSection> sections)
{
this.Find = find;
this.Sections = sections;
}
public ISet<IntermediateSection> Sections { get; }
public FindEntrySectionAndLoadSymbolsCommand Find { get; }
public void Execute()
{
if (this.Find.EntrySection.Type == SectionType.Package
&& !this.Sections.Where(s => s.Id != DefaultFeatureName)
.SelectMany(s => s.Symbols).OfType<FeatureSymbol>().Any())
{
var addedToDefaultFeature = false;
foreach (var section in this.Sections)
{
var components = section.Symbols.OfType<ComponentSymbol>().ToList();
foreach (var component in components)
{
this.Find.EntrySection.AddSymbol(new WixComplexReferenceSymbol(component.SourceLineNumbers)
{
Parent = DefaultFeatureName,
ParentType = ComplexReferenceParentType.Feature,
ParentLanguage = null,
Child = component.Id.Id,
ChildType = ComplexReferenceChildType.Component,
IsPrimary = true,
});
this.Find.EntrySection.AddSymbol(new WixGroupSymbol(component.SourceLineNumbers)
{
ParentId = DefaultFeatureName,
ParentType = ComplexReferenceParentType.Feature,
ChildId = component.Id.Id,
ChildType = ComplexReferenceChildType.Component,
});
addedToDefaultFeature = true;
}
}
if (addedToDefaultFeature)
{
this.Find.EntrySection.AddSymbol(new FeatureSymbol(null, new Identifier(AccessModifier.Virtual, DefaultFeatureName))
{
Level = 1,
Display = 0,
InstallDefault = FeatureInstallDefault.Local,
});
}
}
}
}
}
|