@joebigelow / wix-1 / commits / 6ed045ee

Add a managed custom action E2E test

Rob Mensching committed Mar 27, 2024 at 12:15 UTC 6ed045ee1fe69be037a999df2e57122a25f0dedf
6 files changed +122
src/test/msi/TestData/CustomActionTests/ManagedCustomActions/ManagedCustomActions.wixproj new
+6
@@ -0,0 +1,6 @@
1 +<!-- 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. -->
2 +<Project Sdk="WixToolset.Sdk">
3 + <ItemGroup>
4 + <ProjectReference Include="..\TestCA\TestCA.csproj" />
5 + </ItemGroup>
6 +</Project>
src/test/msi/TestData/CustomActionTests/ManagedCustomActions/Package.wxs new
+32
@@ -0,0 +1,32 @@
1 +<!-- 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. -->
2 +
3 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
4 + <Package Name="~Managed Custom Actions" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="41B5F815-E7F6-44E0-B92A-AE95DFF683F9">
5 + <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
6 +
7 + <Feature Id="ProductFeature" Title="Feature with merged modules">
8 + <Component Directory="INSTALLFOLDER">
9 + <File Source="$(sys.SOURCEFILEPATH)" />
10 + </Component>
11 + </Feature>
12 +
13 + <Binary Id="ManagedCA" SourceFile="TestCA.CA.dll" />
14 +
15 + <CustomAction Id="ImmediateCA" BinaryRef="ManagedCA" DllEntry="ImmediateCA" Execute="immediate" Return="check" />
16 + <CustomAction Id="DeferredCA" BinaryRef="ManagedCA" DllEntry="DeferredCA" Execute="deferred" Return="check" />
17 +
18 + <InstallUISequence>
19 + <Custom Action="ImmediateCA" Before="CostFinalize" />
20 + </InstallUISequence>
21 +
22 + <InstallExecuteSequence>
23 + <Custom Action="DeferredCA" After="InstallFiles" />
24 + </InstallExecuteSequence>
25 + </Package>
26 +
27 + <Fragment>
28 + <StandardDirectory Id="ProgramFilesFolder">
29 + <Directory Id="INSTALLFOLDER" Name="ManagedCA" />
30 + </StandardDirectory>
31 + </Fragment>
32 +</Wix>
src/test/msi/TestData/CustomActionTests/TestCA/CustomAction.config new
+17
@@ -0,0 +1,17 @@
1 +<?xml version="1.0" encoding="utf-8" ?>
2 +<configuration>
3 + <startup useLegacyV2RuntimeActivationPolicy="true">
4 + <!--
5 + Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
6 + the custom action should run on. If no versions are specified, the chosen version of the runtime
7 + will be the "best" match to what WixToolset.Dtf.CustomAction.dll was built against.
8 +
9 + WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
10 + problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
11 + only the version(s) of the .NET Framework runtime that you have tested against.
12 +
13 + For more information https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/startup-element
14 + -->
15 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
16 + </startup>
17 +</configuration>
src/test/msi/TestData/CustomActionTests/TestCA/CustomAction.cs new
+28
@@ -0,0 +1,28 @@
1 +// 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.
2 +
3 +namespace WixToolsetTest.TestCA
4 +{
5 + using System;
6 + using System.Collections.Generic;
7 + using System.Linq;
8 + using WixToolset.Dtf.WindowsInstaller;
9 +
10 + public class CustomActions
11 + {
12 + [CustomAction]
13 + public static ActionResult ImmediateCA(Session session)
14 + {
15 + session.Log("Begin ImmediateCA");
16 +
17 + return ActionResult.Success;
18 + }
19 +
20 + [CustomAction]
21 + public static ActionResult DeferredCA(Session session)
22 + {
23 + session.Log("Begin DeferredCA");
24 +
25 + return ActionResult.Success;
26 + }
27 + }
28 +}
src/test/msi/TestData/CustomActionTests/TestCA/TestCA.csproj new
+16
@@ -0,0 +1,16 @@
1 +<!-- 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. -->
2 +
3 +<Project Sdk="Microsoft.NET.Sdk">
4 + <PropertyGroup>
5 + <TargetFramework>net472</TargetFramework>
6 + </PropertyGroup>
7 +
8 + <ItemGroup>
9 + <Content Include="CustomAction.config" CopyToOutputDirectory="PreserveNewest" />
10 + </ItemGroup>
11 +
12 + <ItemGroup>
13 + <PackageReference Include="WixToolset.Dtf.CustomAction" />
14 + <PackageReference Include="WixToolset.Dtf.WindowsInstaller" />
15 + </ItemGroup>
16 +</Project>
src/test/msi/WixToolsetTest.MsiE2E/CustomActionTests.cs new
+23
@@ -0,0 +1,23 @@
1 +// 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.
2 +
3 +namespace WixToolsetTest.MsiE2E
4 +{
5 + using System;
6 + using WixTestTools;
7 + using Xunit;
8 + using Xunit.Abstractions;
9 +
10 + public class CustomActionTests : MsiE2ETests
11 + {
12 + public CustomActionTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
13 +
14 + [RuntimeFact]
15 + public void CanInstallAndUninstallWithManagedCustomAction()
16 + {
17 + var product = this.CreatePackageInstaller("ManagedCustomActions");
18 + product.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
19 +
20 + product.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
21 + }
22 + }
23 +}