diff options
-rw-r--r-- | nuget.config | 1 | ||||
-rw-r--r-- | src/TestData/BasicFunctionality/BundleA/BundleA.wixproj | 12 | ||||
-rw-r--r-- | src/TestData/BasicFunctionality/BundleA/BundleA.wxi | 21 | ||||
-rw-r--r-- | src/TestData/BasicFunctionality/BundleA/BundleA.wxs | 11 | ||||
-rw-r--r-- | src/TestData/BasicFunctionality/PackageA/PackageA.wixproj | 10 | ||||
-rw-r--r-- | src/Wix.Build.props | 1 | ||||
-rw-r--r-- | src/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs | 41 | ||||
-rw-r--r-- | src/WixToolsetTest.BurnE2E/BundleInstaller.cs | 62 | ||||
-rw-r--r-- | src/WixToolsetTest.BurnE2E/WixToolsetTest.BurnE2E.csproj | 8 |
9 files changed, 160 insertions, 7 deletions
diff --git a/nuget.config b/nuget.config index dd67462a..0d7536b8 100644 --- a/nuget.config +++ b/nuget.config | |||
@@ -4,6 +4,7 @@ | |||
4 | <clear /> | 4 | <clear /> |
5 | <add key="wixtoolset-balutil" value="https://ci.appveyor.com/nuget/wixtoolset-balutil" /> | 5 | <add key="wixtoolset-balutil" value="https://ci.appveyor.com/nuget/wixtoolset-balutil" /> |
6 | <add key="wixtoolset-bal-wixext" value="https://ci.appveyor.com/nuget/wixtoolset-bal-wixext" /> | 6 | <add key="wixtoolset-bal-wixext" value="https://ci.appveyor.com/nuget/wixtoolset-bal-wixext" /> |
7 | <add key="wixtoolset-data" value="https://ci.appveyor.com/nuget/wixtoolset-data" /> | ||
7 | <add key="wixtoolset-dtf" value="https://ci.appveyor.com/nuget/wixtoolset-dtf" /> | 8 | <add key="wixtoolset-dtf" value="https://ci.appveyor.com/nuget/wixtoolset-dtf" /> |
8 | <add key="wixtoolset-netfx-wixext" value="https://ci.appveyor.com/nuget/wixtoolset-netfx-wixext" /> | 9 | <add key="wixtoolset-netfx-wixext" value="https://ci.appveyor.com/nuget/wixtoolset-netfx-wixext" /> |
9 | <add key="wixtoolset-tools" value="https://ci.appveyor.com/nuget/wixtoolset-tools" /> | 10 | <add key="wixtoolset-tools" value="https://ci.appveyor.com/nuget/wixtoolset-tools" /> |
diff --git a/src/TestData/BasicFunctionality/BundleA/BundleA.wixproj b/src/TestData/BasicFunctionality/BundleA/BundleA.wixproj new file mode 100644 index 00000000..45127b23 --- /dev/null +++ b/src/TestData/BasicFunctionality/BundleA/BundleA.wixproj | |||
@@ -0,0 +1,12 @@ | |||
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 | <PropertyGroup> | ||
4 | <OutputType>Bundle</OutputType> | ||
5 | </PropertyGroup> | ||
6 | <ItemGroup> | ||
7 | <ProjectReference Include="..\PackageA\PackageA.wixproj" /> | ||
8 | </ItemGroup> | ||
9 | <ItemGroup> | ||
10 | <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.77" /> | ||
11 | </ItemGroup> | ||
12 | </Project> \ No newline at end of file | ||
diff --git a/src/TestData/BasicFunctionality/BundleA/BundleA.wxi b/src/TestData/BasicFunctionality/BundleA/BundleA.wxi new file mode 100644 index 00000000..0bad694e --- /dev/null +++ b/src/TestData/BasicFunctionality/BundleA/BundleA.wxi | |||
@@ -0,0 +1,21 @@ | |||
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 | <?ifndef Version?> | ||
4 | <?define Version = 1.0.0.0?> | ||
5 | <?endif?> | ||
6 | |||
7 | <Include xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"> | ||
8 | <Bundle Name="~$(var.TestGroupName) - Bundle A" Version="$(var.Version)" UpgradeCode="{8C7E2C47-1EE7-4BBE-99A2-EAB7F3693F48}" Compressed="yes"> | ||
9 | <Log Prefix="~$(var.TestGroupName)_BundleA" /> | ||
10 | |||
11 | <Variable Name="TestGroupName" Value="$(var.TestGroupName)" /> | ||
12 | |||
13 | <BootstrapperApplication> | ||
14 | <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" /> | ||
15 | </BootstrapperApplication> | ||
16 | |||
17 | <Chain> | ||
18 | <PackageGroupRef Id="BundlePackages" /> | ||
19 | </Chain> | ||
20 | </Bundle> | ||
21 | </Include> | ||
diff --git a/src/TestData/BasicFunctionality/BundleA/BundleA.wxs b/src/TestData/BasicFunctionality/BundleA/BundleA.wxs new file mode 100644 index 00000000..0506f05a --- /dev/null +++ b/src/TestData/BasicFunctionality/BundleA/BundleA.wxs | |||
@@ -0,0 +1,11 @@ | |||
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 | |||
4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
5 | <?include BundleA.wxi ?> | ||
6 | <Fragment> | ||
7 | <PackageGroup Id="BundlePackages"> | ||
8 | <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" /> | ||
9 | </PackageGroup> | ||
10 | </Fragment> | ||
11 | </Wix> | ||
diff --git a/src/TestData/BasicFunctionality/PackageA/PackageA.wixproj b/src/TestData/BasicFunctionality/PackageA/PackageA.wixproj new file mode 100644 index 00000000..9943717c --- /dev/null +++ b/src/TestData/BasicFunctionality/PackageA/PackageA.wixproj | |||
@@ -0,0 +1,10 @@ | |||
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 | <PropertyGroup> | ||
4 | <CabPrefix>a</CabPrefix> | ||
5 | <UpgradeCode>{7FD50F1B-D134-4365-923C-DFA160F74738}</UpgradeCode> | ||
6 | </PropertyGroup> | ||
7 | <ItemGroup> | ||
8 | <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" /> | ||
9 | </ItemGroup> | ||
10 | </Project> \ No newline at end of file | ||
diff --git a/src/Wix.Build.props b/src/Wix.Build.props index 050ec6d5..3f3aaf8f 100644 --- a/src/Wix.Build.props +++ b/src/Wix.Build.props | |||
@@ -2,6 +2,7 @@ | |||
2 | <Project> | 2 | <Project> |
3 | <PropertyGroup> | 3 | <PropertyGroup> |
4 | <TestGroupName Condition=" '$(TestGroupName)'=='' ">$([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))))</TestGroupName> | 4 | <TestGroupName Condition=" '$(TestGroupName)'=='' ">$([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))))</TestGroupName> |
5 | <BaseIntermediateOutputPath>$(BaseOutputPath)obj\$(TestGroupName)\$(ProjectName)\</BaseIntermediateOutputPath> | ||
5 | <OutputPath>$(OutputPath)$(TestGroupName)\</OutputPath> | 6 | <OutputPath>$(OutputPath)$(TestGroupName)\</OutputPath> |
6 | </PropertyGroup> | 7 | </PropertyGroup> |
7 | </Project> | 8 | </Project> |
diff --git a/src/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs b/src/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs new file mode 100644 index 00000000..4982d733 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs | |||
@@ -0,0 +1,41 @@ | |||
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.BurnE2E | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using Xunit; | ||
8 | using Xunit.Abstractions; | ||
9 | |||
10 | public class BasicFunctionalityTests : BurnE2ETests | ||
11 | { | ||
12 | public BasicFunctionalityTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper, "BasicFunctionality") { } | ||
13 | |||
14 | [Fact] | ||
15 | public void CanInstallAndUninstallSimpleBundle() | ||
16 | { | ||
17 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
18 | |||
19 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
20 | |||
21 | var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); | ||
22 | |||
23 | // Source file should *not* be installed | ||
24 | Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); | ||
25 | |||
26 | bundleA.Install(); | ||
27 | |||
28 | var cachedBundlePath = bundleA.VerifyRegisteredAndInPackageCache(); | ||
29 | |||
30 | // Source file should be installed | ||
31 | Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); | ||
32 | |||
33 | bundleA.Uninstall(cachedBundlePath); | ||
34 | |||
35 | // Source file should *not* be installed | ||
36 | Assert.False(File.Exists(packageASourceCodeInstalled), String.Concat("Package A payload should have been removed by uninstall from: ", packageASourceCodeInstalled)); | ||
37 | |||
38 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(cachedBundlePath); | ||
39 | } | ||
40 | } | ||
41 | } | ||
diff --git a/src/WixToolsetTest.BurnE2E/BundleInstaller.cs b/src/WixToolsetTest.BurnE2E/BundleInstaller.cs index b708db40..c85646bb 100644 --- a/src/WixToolsetTest.BurnE2E/BundleInstaller.cs +++ b/src/WixToolsetTest.BurnE2E/BundleInstaller.cs | |||
@@ -4,19 +4,30 @@ namespace WixToolsetTest.BurnE2E | |||
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.IO; | 6 | using System.IO; |
7 | using System.Linq; | ||
7 | using System.Text; | 8 | using System.Text; |
9 | using Microsoft.Win32; | ||
10 | using WixToolset.Data; | ||
11 | using WixToolset.Data.Symbols; | ||
12 | using Xunit; | ||
8 | 13 | ||
9 | public class BundleInstaller : IDisposable | 14 | public class BundleInstaller : IDisposable |
10 | { | 15 | { |
16 | public const string BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
17 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH = "BundleCachePath"; | ||
18 | |||
11 | public BundleInstaller(WixTestContext testContext, string name) | 19 | public BundleInstaller(WixTestContext testContext, string name) |
12 | { | 20 | { |
13 | this.Bundle = Path.Combine(testContext.TestDataFolder, $"{name}.exe"); | 21 | this.Bundle = Path.Combine(testContext.TestDataFolder, $"{name}.exe"); |
22 | this.BundlePdb = Path.Combine(testContext.TestDataFolder, $"{name}.wixpdb"); | ||
14 | this.TestGroupName = testContext.TestGroupName; | 23 | this.TestGroupName = testContext.TestGroupName; |
15 | this.TestName = testContext.TestName; | 24 | this.TestName = testContext.TestName; |
16 | } | 25 | } |
17 | 26 | ||
18 | public string Bundle { get; } | 27 | public string Bundle { get; } |
19 | 28 | ||
29 | public string BundlePdb { get; } | ||
30 | |||
20 | public string TestGroupName { get; } | 31 | public string TestGroupName { get; } |
21 | 32 | ||
22 | public string TestName { get; } | 33 | public string TestName { get; } |
@@ -66,15 +77,27 @@ namespace WixToolsetTest.BurnE2E | |||
66 | } | 77 | } |
67 | 78 | ||
68 | /// <summary> | 79 | /// <summary> |
80 | /// Uninstalls the bundle at the given path with optional arguments. | ||
81 | /// </summary> | ||
82 | /// <param name="bundlePath">This should be the bundle in the package cache.</param> | ||
83 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
84 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
85 | /// <returns>Path to the generated log file.</returns> | ||
86 | public string Uninstall(string bundlePath, int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
87 | { | ||
88 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Uninstall, arguments, bundlePath: bundlePath); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
69 | /// Executes the bundle with optional arguments. | 92 | /// Executes the bundle with optional arguments. |
70 | /// </summary> | 93 | /// </summary> |
71 | /// <param name="expectedExitCode">Expected exit code.</param> | 94 | /// <param name="expectedExitCode">Expected exit code.</param> |
72 | /// <param name="mode">Install mode.</param> | 95 | /// <param name="mode">Install mode.</param> |
73 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | 96 | /// <param name="arguments">Optional arguments to pass to the tool.</param> |
74 | /// <returns>Path to the generated log file.</returns> | 97 | /// <returns>Path to the generated log file.</returns> |
75 | private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, string[] arguments, bool assertOnError = true) | 98 | private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, string[] arguments, bool assertOnError = true, string bundlePath = null) |
76 | { | 99 | { |
77 | TestTool bundle = new TestTool(this.Bundle); | 100 | TestTool bundle = new TestTool(bundlePath ?? this.Bundle); |
78 | var sb = new StringBuilder(); | 101 | var sb = new StringBuilder(); |
79 | 102 | ||
80 | // Be sure to run silent. | 103 | // Be sure to run silent. |
@@ -119,6 +142,41 @@ namespace WixToolsetTest.BurnE2E | |||
119 | return logFile; | 142 | return logFile; |
120 | } | 143 | } |
121 | 144 | ||
145 | public string VerifyRegisteredAndInPackageCache() | ||
146 | { | ||
147 | using var wixOutput = WixOutput.Read(this.BundlePdb); | ||
148 | var intermediate = Intermediate.Load(wixOutput); | ||
149 | var section = intermediate.Sections.Single(); | ||
150 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
151 | var bundleId = bundleSymbol.BundleId; | ||
152 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; | ||
153 | |||
154 | using var testKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); | ||
155 | Assert.NotNull(testKey); | ||
156 | |||
157 | var cachePathValue = testKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH); | ||
158 | Assert.NotNull(cachePathValue); | ||
159 | var cachePath = Assert.IsType<string>(cachePathValue); | ||
160 | Assert.True(File.Exists(cachePath)); | ||
161 | |||
162 | return cachePath; | ||
163 | } | ||
164 | |||
165 | public void VerifyUnregisteredAndRemovedFromPackageCache(string cachedBundlePath) | ||
166 | { | ||
167 | using var wixOutput = WixOutput.Read(this.BundlePdb); | ||
168 | var intermediate = Intermediate.Load(wixOutput); | ||
169 | var section = intermediate.Sections.Single(); | ||
170 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
171 | var bundleId = bundleSymbol.BundleId; | ||
172 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; | ||
173 | |||
174 | using var testKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); | ||
175 | Assert.Null(testKey); | ||
176 | |||
177 | Assert.False(File.Exists(cachedBundlePath)); | ||
178 | } | ||
179 | |||
122 | public void Dispose() | 180 | public void Dispose() |
123 | { | 181 | { |
124 | string[] args = { "-burn.ignoredependencies=ALL" }; | 182 | string[] args = { "-burn.ignoredependencies=ALL" }; |
diff --git a/src/WixToolsetTest.BurnE2E/WixToolsetTest.BurnE2E.csproj b/src/WixToolsetTest.BurnE2E/WixToolsetTest.BurnE2E.csproj index 78dbaf74..988834b2 100644 --- a/src/WixToolsetTest.BurnE2E/WixToolsetTest.BurnE2E.csproj +++ b/src/WixToolsetTest.BurnE2E/WixToolsetTest.BurnE2E.csproj | |||
@@ -4,16 +4,14 @@ | |||
4 | <Project Sdk="Microsoft.NET.Sdk"> | 4 | <Project Sdk="Microsoft.NET.Sdk"> |
5 | <PropertyGroup> | 5 | <PropertyGroup> |
6 | <TargetFramework>netcoreapp3.1</TargetFramework> | 6 | <TargetFramework>netcoreapp3.1</TargetFramework> |
7 | </PropertyGroup> | 7 | <PlatformTarget>x64</PlatformTarget> |
8 | |||
9 | <PropertyGroup> | ||
10 | <NoWarn>NU1701</NoWarn> | ||
11 | </PropertyGroup> | 8 | </PropertyGroup> |
12 | 9 | ||
13 | <ItemGroup> | 10 | <ItemGroup> |
14 | <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> | 11 | <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> |
15 | <PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" /> | 12 | <PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" /> |
16 | <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" /> | 13 | <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.48" /> |
14 | <PackageReference Include="WixToolset.Data" Version="4.0.177" /> | ||
17 | </ItemGroup> | 15 | </ItemGroup> |
18 | 16 | ||
19 | <ItemGroup> | 17 | <ItemGroup> |