Skip to content

Commit

Permalink
Fix Enforce.
Browse files Browse the repository at this point in the history
  • Loading branch information
rseanhall committed Mar 5, 2021
1 parent 5d22e83 commit 3eef7b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WixToolsetTest.Dependency
{
using System.Linq;
using System.Text.RegularExpressions;
using WixBuildTools.TestSupport;
using WixToolset.Core.TestPackage;
using WixToolset.Dependency;
Expand All @@ -15,11 +17,15 @@ public void CanBuildUsingProvides()
var folder = TestData.Get(@"TestData\UsingProvides");
var build = new Builder(folder, typeof(DependencyExtensionFactory), new[] { folder });

var results = build.BuildAndQuery(Build, "CustomAction", "WixDependencyProvider");
Assert.Equal(new[]
var results = build.BuildAndQuery(Build, "CustomAction", "WixDependencyProvider")
.Select(r => Regex.Replace(r, "{[^}]*}", "{*}"))
.ToArray();
WixAssert.CompareLineByLine(new[]
{
"CustomAction:Wix4DependencyCheck_X86\t1\tDependencyCA_X86\tWixDependencyCheck\t",
"CustomAction:Wix4DependencyRequire_X86\t1\tDependencyCA_X86\tWixDependencyRequire\t",
"WixDependencyProvider:dep74OfIcniaqxA7EprRGBw4Oyy3r8\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tUsingProvides\t\t\t",
"WixDependencyProvider:depTpv28q7slcxvXPWmU4Z0GfbiI.4\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\t{*}\t\t\t",
}, results);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<Component Directory="INSTALLFOLDER">
<File Name="example.txt" Source="Package.wxs" />
<Provides Key="UsingProvides" dep:Check="yes" />
<Provides>
<Requires ProviderKey="UsingRequires" Minimum="1.0.0.0" dep:Enforce="yes" />
</Provides>
</Component>
</Feature>

Expand Down
4 changes: 2 additions & 2 deletions src/wixext/DependencyCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public override void ParseAttribute(Intermediate intermediate, IntermediateSecti
switch (parentElement.Name.LocalName)
{
case "Provides":
if (attribute.Name.LocalName == "Check" && parentElement.Parent.Name.LocalName == "Component")
if (attribute.Name.LocalName == "Check" && parentElement.Parent?.Name.LocalName == "Component")
{
addCheck = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute);
}
break;
case "Requires":
case "RequiresRef":
if (attribute.Name.LocalName == "Enforce" && parentElement.Parent.Name.LocalName == "Component")
if (attribute.Name.LocalName == "Enforce" && parentElement.Parent?.Parent?.Name.LocalName == "Component")
{
addRequire = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wixlib/DependencyExtension_Platform.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Fragment>
<CustomAction Id="$(var.Prefix)DependencyRequire$(var.Suffix)" DllEntry="WixDependencyRequire" Execute="immediate" Return="check" SuppressModularization="yes" BinaryRef="DependencyCA$(var.Suffix)" />
<InstallExecuteSequence>
<Custom Action="$(var.Prefix)DependencyRequire$(var.Suffix)" Before="WixDependencyCheck$(var.Suffix)" Overridable="yes" Condition="NOT DISABLEDEPENDENCYCHECK" />
<Custom Action="$(var.Prefix)DependencyRequire$(var.Suffix)" Before="$(var.Prefix)DependencyCheck$(var.Suffix)" Overridable="yes" Condition="NOT DISABLEDEPENDENCYCHECK" />
</InstallExecuteSequence>
<UIRef Id="WixDependencyErrors" />
<PropertyRef Id="DISABLEDEPENDENCYCHECK" />
Expand Down

0 comments on commit 3eef7b6

Please sign in to comment.