Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/burn/engine/registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,6 @@ extern "C" HRESULT RegistrationSessionBegin(
ExitOnFailure(hr, "Failed to write software tags.");
}

// Update registration.
if (pRegistration->update.fRegisterUpdate)
{
hr = WriteUpdateRegistration(pRegistration, pVariables);
ExitOnFailure(hr, "Failed to write update registration.");
}

// Only set install date and initial estimated size here for the first time.
// Estimated size will always get updated at the end of the session.
if (fCreated)
Expand Down Expand Up @@ -904,6 +897,13 @@ extern "C" HRESULT RegistrationSessionEnd(

hr = UpdateEstimatedSize(hkRegistration, qwEstimatedSize);
ExitOnFailure(hr, "Failed to update estimated size.");

// Update registration.
if (pRegistration->update.fRegisterUpdate)
{
hr = WriteUpdateRegistration(pRegistration, pVariables);
ExitOnFailure(hr, "Failed to write update registration.");
}
}

// Update resume mode.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!-- 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. -->

<?ifndef TestVersion?>
<?define TestVersion = 1.0.0.0?>
<?endif?>
<?ifndef BundleLogDirectory?>
<?define BundleLogDirectory = .?>
<?endif?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Name="~$(TestGroupName)" Version="$(TestVersion)" Manufacturer="Acme" UpgradeCode="$(UpgradeCode)" Compressed="yes">
<Log Prefix="$(BundleLogDirectory)\~$(TestGroupName)_$(BundleName)" />

<Variable Name="TestGroupName" Value="$(TestGroupName)" />

<OptionalUpdateRegistration ProductFamily="GreetingsAndFelicitations" Department="Setup Geeks" Classification="Bundle" />

<?ifdef SoftwareTag?>
<SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]TestingSwidTags" />
<?endif?>

<?ifndef BA?>
<!-- pulled in through the PackageGroupRef below -->
<?elseif $(BA) = "TestBA_x64"?>
<!-- pulled in through the PackageGroupRef below -->
<?elseif $(BA) = "WixBA"?>
<!-- pulled in through the PackageGroupRef below -->
<?elseif $(BA) = "hyperlinkLicense"?>
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" />
<PayloadGroupRef Id="ExtraPayloads" />
</BootstrapperApplication>
<?elseif $(BA) = "iui"?>
<BootstrapperApplication>
<bal:WixInternalUIBootstrapperApplication />
</BootstrapperApplication>
<?else?>
<BootstrapperApplicationRef Id="$(BA)" />
<?endif?>

<Chain>
<?ifndef BA?>
<PackageGroupRef Id="TestBA" />
<?elseif $(BA) = "TestBA_x64"?>
<PackageGroupRef Id="TestBA_x64" />
<?elseif $(BA) = "WixBA"?>
<PackageGroupRef Id="WixBA" />
<?endif?>

<PackageGroupRef Id="BundlePackages" />
</Chain>
</Bundle>

<Fragment>
<PayloadGroup Id="virtual ExtraPayloads" />
</Fragment>

</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- 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. -->
<Project>
<PropertyGroup>
<OutputType>Bundle</OutputType>
<BA>hyperlinkLicense</BA>
<UpgradeCode>{9510DDE7-CD4F-45B3-9D57-3F7EA04DB33D}</UpgradeCode>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- 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. -->
<Project Sdk="WixToolset.Sdk">
<Import Project="BundleA.props" />
<ItemGroup>
<ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" />
<ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.BootstrapperApplications.wixext" />
<PackageReference Include="WixToolset.NetFx.wixext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 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. -->


<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<PackageGroup Id="BundlePackages">
<MsiPackage Id="PackageA" SourceFile="$(var.PackageAv1.TargetPath)" />
</PackageGroup>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- 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. -->
<Project Sdk="WixToolset.Sdk">
<Import Project="..\BundleAv1\BundleA.props" />
<PropertyGroup>
<TestVersion>2.0.0.0</TestVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\BundleAv1\Bundle.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PackageAv2\PackageAv2.wixproj" />
<ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.BootstrapperApplications.wixext" />
<PackageReference Include="WixToolset.NetFx.wixext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- 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. -->


<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<PackageGroup Id="BundlePackages">
<MsiPackage Id="PackageA" SourceFile="$(var.PackageAv2.TargetPath)" />
</PackageGroup>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- 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. -->
<Project>
<PropertyGroup>
<UpgradeCode>{30746E93-9A4A-48EC-BAEA-3093A2530E73}</UpgradeCode>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- 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. -->
<Project Sdk="WixToolset.Sdk">
<Import Project="PackageA.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- 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. -->
<Project Sdk="WixToolset.Sdk">
<Import Project="..\PackageAv1\PackageA.props" />
<PropertyGroup>
<TestVersion>2.0.0.0</TestVersion>
</PropertyGroup>
</Project>
57 changes: 57 additions & 0 deletions src/test/burn/WixTestTools/BundleUpdateRegistration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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 WixTestTools
{
using System;
using Microsoft.Win32;

public class BundleUpdateRegistration
{
public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_NAME = "PackageName";
public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_VERSION = "PackageVersion";
public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHER = "Publisher";
public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHING_GROUP = "PublishingGroup";

public string PackageName { get; set; }

public string PackageVersion { get; set; }

public string Publisher { get; set; }

public string PublishingGroup { get; set; }

public static bool TryGetPerMachineBundleUpdateRegistration(string manufacturer, string productFamily, string name, bool x64, out BundleUpdateRegistration registration)
{
return TryGetUpdateRegistration(manufacturer, productFamily, name, x64, perUser: false, out registration);
}

public static bool TryGetPerUserBundleUpdateRegistration(string manufacturer, string productFamily, string name, out BundleUpdateRegistration registration)
{
return TryGetUpdateRegistration(manufacturer, productFamily, name, x64: true, perUser: true, out registration);
}

private static bool TryGetUpdateRegistration(string manufacturer, string productFamily, string name, bool x64, bool perUser, out BundleUpdateRegistration registration)
{
var baseKey = perUser ? Registry.CurrentUser : Registry.LocalMachine;
var baseKeyPath = x64 ? @$"SOFTWARE\{manufacturer}\Updates\{productFamily}\{name}"
: @$"SOFTWARE\WOW6432Node\{manufacturer}\Updates\{productFamily}\{name}";
using var idKey = baseKey.OpenSubKey(baseKeyPath);

if (idKey == null)
{
registration = null;
return false;
}

registration = new BundleUpdateRegistration()
{
PackageName = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_NAME) as string,
PackageVersion = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_VERSION) as string,
Publisher = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHER) as string,
PublishingGroup = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHING_GROUP) as string,
};

return true;
}
}
}
37 changes: 37 additions & 0 deletions src/test/burn/WixTestTools/BundleVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace WixTestTools
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.Win32;
using WixInternal.TestSupport;
using WixToolset.Data;
Expand All @@ -23,6 +24,8 @@ public partial class BundleInstaller

private WixBundleSymbol BundleSymbol { get; set; }

private WixUpdateRegistrationSymbol UpdateRegistrationSymbol { get; set; }

private WixBundleSymbol GetBundleSymbol()
{
if (this.BundleSymbol == null)
Expand All @@ -36,6 +39,19 @@ private WixBundleSymbol GetBundleSymbol()
return this.BundleSymbol;
}

private WixUpdateRegistrationSymbol GetUpdateRegistrationSymbol()
{
if (this.UpdateRegistrationSymbol == null)
{
using var wixOutput = WixOutput.Read(this.BundlePdb);
var intermediate = Intermediate.Load(wixOutput);
var section = intermediate.Sections.Single();
this.UpdateRegistrationSymbol = section.Symbols.OfType<WixUpdateRegistrationSymbol>().Single();
}

return this.UpdateRegistrationSymbol;
}

public string GetFullBurnPolicyRegistryPath()
{
var bundleSymbol = this.GetBundleSymbol();
Expand Down Expand Up @@ -118,6 +134,27 @@ public bool TryGetRegistration(out BundleRegistration registration)
}
}

public bool TryGetUpdateRegistration(out BundleUpdateRegistration registration)
{
var bundleSymbol = this.GetBundleSymbol();
var x64 = bundleSymbol.Platform != Platform.X86;

var updateRegistrationSymbol = this.GetUpdateRegistrationSymbol();
var manufacturer = updateRegistrationSymbol.Manufacturer;
var productFamily = updateRegistrationSymbol.ProductFamily;
var name = updateRegistrationSymbol.Name;


if (bundleSymbol.PerMachine)
{
return BundleUpdateRegistration.TryGetPerMachineBundleUpdateRegistration(manufacturer, productFamily, name, x64, out registration);
}
else
{
return BundleUpdateRegistration.TryGetPerUserBundleUpdateRegistration(manufacturer, productFamily, name, out registration);
}
}

public BundleRegistration VerifyRegisteredAndInPackageCache(int? expectedSystemComponent = null)
{
Assert.True(this.TryGetRegistration(out var registration));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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.BurnE2E
{
using WixTestTools;
using Xunit;
using Xunit.Abstractions;

public class OptionalUpdateRegistrationTests : BurnE2ETests
{
public OptionalUpdateRegistrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }

[RuntimeFact]
public void BundleUpdateRegistrationIsStickyAndAccurateAcrossUpgrades()
{
var packageAv1 = this.CreatePackageInstaller("PackageAv1");
var packageAv2 = this.CreatePackageInstaller("PackageAv2");
var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
var bundleAv2 = this.CreateBundleInstaller("BundleAv2");

bundleAv1.Install();
bundleAv1.VerifyRegisteredAndInPackageCache();
var gotV1Registration = bundleAv1.TryGetUpdateRegistration(out var v1Registration);

bundleAv2.Install();
bundleAv2.VerifyRegisteredAndInPackageCache();
var gotV2Registration = bundleAv2.TryGetUpdateRegistration(out var v2Registration);

bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();

Assert.True(gotV1Registration, "Missing update registration after v1 install.");
Assert.True(gotV2Registration, "Missing update registration after v2 upgrade.");

Assert.Equal("Acme", v1Registration.Publisher);
Assert.Equal("Acme", v2Registration.Publisher);
Assert.Equal("Setup Geeks", v1Registration.PublishingGroup);
Assert.Equal("Setup Geeks", v2Registration.PublishingGroup);
Assert.Equal("~OptionalUpdateRegistrationTests", v1Registration.PackageName);
Assert.Equal("~OptionalUpdateRegistrationTests", v2Registration.PackageName);
Assert.Equal("1.0.0.0", v1Registration.PackageVersion);
Assert.Equal("2.0.0.0", v2Registration.PackageVersion);
}
}
}