Skip to content

Commit

Permalink
Correctly handle top-level AppId element
Browse files Browse the repository at this point in the history
Fixes 7738
  • Loading branch information
robmen committed Nov 7, 2023
1 parent 96e9c0f commit a886df0
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/api/wix/WixToolset.Data/ErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Message AdvertiseStateMustMatch(SourceLineNumber sourceLineNumbers

public static Message AppIdIncompatibleAdvertiseState(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string parentValue)
{
return Message(sourceLineNumbers, Ids.AppIdIncompatibleAdvertiseState, "The {0}/@(1) attribute's value, '{2}' does not match the advertise state on its parent element: '{3}'. (Note: AppIds nested under Fragment, Module, or Product elements must be advertised.)", elementName, attributeName, value, parentValue);
return Message(sourceLineNumbers, Ids.AppIdIncompatibleAdvertiseState, "The {0}/@(1) attribute's value, '{2}' does not match the advertise state on its parent element: '{3}'. (Note: AppIds nested under Fragment, Module, or Package elements must be advertised.)", elementName, attributeName, value, parentValue);
}

public static Message BaselineRequired()
Expand Down
2 changes: 1 addition & 1 deletion src/wix/WixToolset.Core/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ private void ParseAppIdElement(XElement node, string componentId, YesNoType adve
{
this.Core.Write(ErrorMessages.AppIdIncompatibleAdvertiseState(sourceLineNumbers, node.Name.LocalName, "Advertise", appIdAdvertise.ToString(), advertise.ToString()));
}
else
else if (appIdAdvertise != YesNoType.NotSet)
{
advertise = appIdAdvertise;
}
Expand Down
76 changes: 76 additions & 0 deletions src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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 WixToolsetTest.CoreIntegration
{
using System.IO;
using WixInternal.Core.TestPackage;
using WixInternal.TestSupport;
using Xunit;

public class AppIdFixture
{
[Fact]
public void PopulatesAppIdTableAtTopLevel()
{
var folder = TestData.Get(@"TestData");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var msiPath = Path.Combine(baseFolder, @"bin", "test.msi");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "AppId", "TopLevelAppId.wxs"),
"-bindpath", Path.Combine(folder, "SingleFile", "data"),
"-intermediateFolder", intermediateFolder,
"-o", msiPath
});

result.AssertSuccess();

Assert.True(File.Exists(msiPath));
var results = Query.QueryDatabase(msiPath, new[] { "AppId" });
WixAssert.CompareLineByLine(new[]
{
"AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t",
}, results);
}
}

[Fact]
public void PopulatesAppIdTableWhenAdvertised()
{
var folder = TestData.Get(@"TestData");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var msiPath = Path.Combine(baseFolder, @"bin", "test.msi");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "AppId", "Advertised.wxs"),
Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
"-bindpath", Path.Combine(folder, "SingleFile", "data"),
"-intermediateFolder", intermediateFolder,
"-o", msiPath
});

result.AssertSuccess();

Assert.True(File.Exists(msiPath));
var results = Query.QueryDatabase(msiPath, new[] { "AppId" });
WixAssert.CompareLineByLine(new[]
{
"AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t",
}, results);
}
}
}
}
33 changes: 0 additions & 33 deletions src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,6 @@ namespace WixToolsetTest.CoreIntegration

public class MsiQueryFixture
{
[Fact]
public void PopulatesAppIdTableWhenAdvertised()
{
var folder = TestData.Get(@"TestData");

using (var fs = new DisposableFileSystem())
{
var baseFolder = fs.GetFolder();
var intermediateFolder = Path.Combine(baseFolder, "obj");
var msiPath = Path.Combine(baseFolder, @"bin\test.msi");

var result = WixRunner.Execute(new[]
{
"build",
Path.Combine(folder, "AppId", "Advertised.wxs"),
Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
"-bindpath", Path.Combine(folder, "SingleFile", "data"),
"-intermediateFolder", intermediateFolder,
"-o", msiPath
});

result.AssertSuccess();

Assert.True(File.Exists(msiPath));
var results = Query.QueryDatabase(msiPath, new[] { "AppId" });
WixAssert.CompareLineByLine(new[]
{
"AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t",
}, results);
}
}

[Fact]
public void PopulatesAppSearchTablesFromComponentSearch()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="~AppId Top-Level" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="12E4699F-E774-4D05-8A01-5BDD41BBA127" Compressed="no">
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

<AppId Id="D6040299-B15C-4C94-AE26-0C9B60D14C35" />

<Feature Id="ProductFeature" Title="MsiPackageTitle">
<Component Directory="INSTALLFOLDER">
<File Source="test.txt" />
</Component>
</Feature>
</Package>

<Fragment>
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="MsiPackage" />
</StandardDirectory>
</Fragment>
</Wix>

0 comments on commit a886df0

Please sign in to comment.