Skip to content
/ wix Public

Commit 040e50e

Browse files
committed
Rewrite Prereq tests after hardening and bypassing .NET GUI errors
1 parent ccfed95 commit 040e50e

File tree

11 files changed

+71
-233
lines changed

11 files changed

+71
-233
lines changed

src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wxs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<!-- 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. -->
22

3-
43
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
54
<Fragment>
6-
<BootstrapperApplication Id="BrokenDnc" SourceFile="!(bindpath.dncx86)\TestBA.exe" Secondary="yes">
5+
<BootstrapperApplication Id="BrokenDnc" SourceFile="!(bindpath.dncx86)\TestBA.exe">
76
<Payload SourceFile="!(bindpath.dncx86)\TestBA.deps.json" />
87
<Payload SourceFile="!(bindpath.dncx86)\TestBA.dll" />
98
<Payload Name="good.runtimeconfig.json" SourceFile="!(bindpath.dncx86)\TestBA.runtimeconfig.json" />
10-
<Payload Name="TestBA.runtimeconfig.json" SourceFile="bad.runtimeconfig.json" />
119
<Payload SourceFile="!(bindpath.dncx86)\mbanative.dll" />
1210
<Payload SourceFile="!(bindpath.dncx86)\WixToolset.BootstrapperApplicationApi.dll" />
1311
<Payload SourceFile="$(var.PrereqBaf.TargetPath)" bal:BAFunctions="yes" />
@@ -17,13 +15,12 @@
1715
</Fragment>
1816

1917
<Fragment>
20-
<util:FileSearch Variable="GoodConfigPresent" Path="[BARuntimeDirectory]\good.runtimeconfig.json" Result="exists" />
21-
<Variable Name="CAUSEINFINITELOOP" bal:Overridable="yes" />
18+
<util:FileSearch Variable="TestBAConfigPresent" Path="[BARuntimeDirectory]\TestBA.runtimeconfig.json" Result="exists" />
2219

2320
<PackageGroup Id="BundlePackages">
2421
<ExePackage SourceFile="$(var.ReplaceConfig.TargetPath)" bal:PrereqPackage="yes"
25-
Permanent="yes" DetectCondition="NOT GoodConfigPresent OR CAUSEINFINITELOOP = 1"
26-
InstallArguments="&quot;[BARuntimeDirectory]TestBA.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]good.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]bad.runtimeconfig.json&quot;" />
22+
Permanent="yes" DetectCondition="TestBAConfigPresent"
23+
InstallArguments="&quot;[BARuntimeDirectory]\TestBA.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]\good.runtimeconfig.json&quot;" />
2724
<MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
2825
<MsiPackage Id="PackageC" SourceFile="$(var.PackageC.TargetPath)" Cache="force" />
2926
</PackageGroup>

src/test/burn/TestData/PrereqBaTests/BundleA/bad.runtimeconfig.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wxs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<!-- 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. -->
22

3-
43
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
54
<Fragment>
6-
<BootstrapperApplication Id="BrokenMba" SourceFile="!(bindpath.net2x86)\TestBA.exe"
7-
Secondary="yes">
5+
<BootstrapperApplication Id="BrokenMba" SourceFile="!(bindpath.net2x86)\TestBA.exe">
86
<Payload Name="good.config" SourceFile="!(bindpath.net2x86)\TestBA.exe.config" />
9-
<Payload Name="TestBA.exe.config" SourceFile="bad.config" />
107
<Payload SourceFile="!(bindpath.net2x86)\mbanative.dll" />
118
<Payload SourceFile="!(bindpath.net2x86)\WixToolset.BootstrapperApplicationApi.dll" />
129
<Payload SourceFile="$(var.PrereqBaf.TargetPath)" bal:BAFunctions="yes" />
@@ -16,13 +13,12 @@
1613
</Fragment>
1714

1815
<Fragment>
19-
<util:FileSearch Variable="GoodConfigPresent" Path="[BARuntimeDirectory]\good.config" Result="exists" />
20-
<Variable Name="CAUSEINFINITELOOP" bal:Overridable="yes" />
16+
<util:FileSearch Variable="TestBAConfigPresent" Path="[BARuntimeDirectory]\TestBA.exe.config" Result="exists" />
2117

2218
<PackageGroup Id="BundlePackages">
2319
<ExePackage SourceFile="$(var.ReplaceConfig.TargetPath)" bal:PrereqPackage="yes"
24-
Permanent="yes" DetectCondition="NOT GoodConfigPresent OR CAUSEINFINITELOOP = 1"
25-
InstallArguments="&quot;[BARuntimeDirectory]TestBA.exe.config&quot; &quot;[BARuntimeDirectory]good.config&quot; &quot;[BARuntimeDirectory]bad.config&quot;" />
20+
Permanent="yes" DetectCondition="TestBAConfigPresent"
21+
InstallArguments="&quot;[BARuntimeDirectory]TestBA.exe.config&quot; &quot;[BARuntimeDirectory]good.config&quot;" />
2622
<MsiPackage Id="PackageB" SourceFile="$(var.PackageB.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
2723
<MsiPackage Id="PackageC" SourceFile="$(var.PackageC.TargetPath)" />
2824
</PackageGroup>

src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="WixToolset.Sdk">
33
<PropertyGroup>
44
<OutputType>Bundle</OutputType>
5-
<BA>BrokenDncAlwaysPrereq</BA>
5+
<BA>BrokenDncSecondary</BA>
66
<UpgradeCode>{D2763AB7-979B-485C-AE52-DD03C23CCB93}</UpgradeCode>
77
</PropertyGroup>
88
<ItemGroup>

src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wxs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
44
<Fragment>
5-
<BootstrapperApplication Id="BrokenDncAlwaysPrereq" SourceFile="!(bindpath.dncx86)\TestBA.exe" Secondary="true">
5+
<BootstrapperApplication Id="BrokenDncSecondary" SourceFile="!(bindpath.dncx86)\TestBA.exe" Secondary="yes">
66
<Payload SourceFile="!(bindpath.dncx86)\TestBA.deps.json" />
77
<Payload SourceFile="!(bindpath.dncx86)\TestBA.dll" />
88
<Payload Name="good.runtimeconfig.json" SourceFile="!(bindpath.dncx86)\TestBA.runtimeconfig.json" />
9-
<Payload Name="TestBA.runtimeconfig.json" SourceFile="bad.runtimeconfig.json" />
109
<Payload SourceFile="!(bindpath.dncx86)\mbanative.dll" />
1110
<Payload SourceFile="!(bindpath.dncx86)\WixToolset.BootstrapperApplicationApi.dll" />
1211
<Payload SourceFile="$(var.PrereqBaf.TargetPath)" bal:BAFunctions="yes" />
@@ -16,13 +15,12 @@
1615
</Fragment>
1716

1817
<Fragment>
19-
<util:FileSearch Variable="GoodConfigPresent" Path="[BARuntimeDirectory]\good.runtimeconfig.json" Result="exists" />
20-
<Variable Name="CAUSEINFINITELOOP" bal:Overridable="yes" />
18+
<util:FileSearch Variable="TestBAConfigPresent" Path="[BARuntimeDirectory]TestBA.runtimeconfig.json" Result="exists" />
2119

2220
<PackageGroup Id="BundlePackages">
2321
<ExePackage SourceFile="$(var.ReplaceConfig.TargetPath)" bal:PrereqPackage="yes"
24-
Permanent="yes" DetectCondition="NOT GoodConfigPresent OR CAUSEINFINITELOOP = 1"
25-
InstallArguments="&quot;[BARuntimeDirectory]TestBA.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]good.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]bad.runtimeconfig.json&quot;" />
22+
Permanent="yes" DetectCondition="TestBAConfigPresent"
23+
InstallArguments="&quot;[BARuntimeDirectory]TestBA.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]good.runtimeconfig.json&quot;" />
2624
<MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
2725
<MsiPackage Id="PackageC" SourceFile="$(var.PackageC.TargetPath)" Cache="force" />
2826
</PackageGroup>

src/test/burn/TestData/PrereqBaTests/BundleC/bad.runtimeconfig.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="WixToolset.Sdk">
33
<PropertyGroup>
44
<OutputType>Bundle</OutputType>
5-
<BA>BrokenMbaAlwaysPrereq</BA>
5+
<BA>BrokenMbaSecondary</BA>
66
<UpgradeCode>{415CA128-60E1-4D16-ACE8-A1D43E98B997}</UpgradeCode>
77
</PropertyGroup>
88
<ItemGroup>

src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wxs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<!-- 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. -->
22

3-
43
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
54
<Fragment>
6-
<BootstrapperApplication Id="BrokenMbaAlwaysPrereq" SourceFile="!(bindpath.net2x86)\TestBA.exe" Secondary="true">
5+
<BootstrapperApplication Id="BrokenMbaSecondary" SourceFile="!(bindpath.net2x86)\TestBA.exe" Secondary="true">
76
<Payload Name="good.config" SourceFile="!(bindpath.net2x86)\TestBA.exe.config" />
8-
<Payload Name="TestBA.exe.config" SourceFile="bad.config" />
97
<Payload SourceFile="!(bindpath.net2x86)\mbanative.dll" />
108
<Payload SourceFile="!(bindpath.net2x86)\WixToolset.BootstrapperApplicationApi.dll" />
119
<Payload SourceFile="$(var.PrereqBaf.TargetPath)" bal:BAFunctions="yes" />
@@ -15,13 +13,12 @@
1513
</Fragment>
1614

1715
<Fragment>
18-
<util:FileSearch Variable="GoodConfigPresent" Path="[BARuntimeDirectory]\good.config" Result="exists" />
19-
<Variable Name="CAUSEINFINITELOOP" bal:Overridable="yes" />
16+
<util:FileSearch Variable="TestBAConfigPresent" Path="[BARuntimeDirectory]\TestBA.exe.config" Result="exists" />
2017

2118
<PackageGroup Id="BundlePackages">
2219
<ExePackage SourceFile="$(var.ReplaceConfig.TargetPath)" bal:PrereqPackage="yes"
23-
Permanent="yes" DetectCondition="NOT GoodConfigPresent OR CAUSEINFINITELOOP = 1"
24-
InstallArguments="&quot;[BARuntimeDirectory]TestBA.exe.config&quot; &quot;[BARuntimeDirectory]good.config&quot; &quot;[BARuntimeDirectory]bad.config&quot;" />
20+
Permanent="yes" DetectCondition="TestBAConfigPresent"
21+
InstallArguments="&quot;[BARuntimeDirectory]TestBA.exe.config&quot; &quot;[BARuntimeDirectory]good.config&quot;" />
2522
<MsiPackage Id="PackageB" SourceFile="$(var.PackageB.TargetPath)" bal:PrereqPackage="yes" Permanent="yes" />
2623
<MsiPackage Id="PackageC" SourceFile="$(var.PackageC.TargetPath)" />
2724
</PackageGroup>

src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
</Fragment>
1515

1616
<Fragment>
17-
<util:FileSearch Variable="GoodConfigPresent" Path="[BARuntimeDirectory]\good.runtimeconfig.json" Result="exists" />
17+
<util:FileSearch Variable="TestBAConfigPresent" Path="[BARuntimeDirectory]\good.runtimeconfig.json" Result="exists" />
1818

1919
<PackageGroup Id="BundlePackages">
2020
<ExePackage SourceFile="$(var.ReplaceConfig.TargetPath)" bal:PrereqPackage="yes"
21-
Permanent="yes" DetectCondition="NOT GoodConfigPresent"
21+
Permanent="yes" DetectCondition="NOT TestBAConfigPresent"
2222
InstallArguments="&quot;[BARuntimeDirectory]TestBA.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]good.runtimeconfig.json&quot; &quot;[BARuntimeDirectory]bad.runtimeconfig.json&quot;" />
2323
</PackageGroup>
2424
</Fragment>

src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,31 @@ int __cdecl wmain(
77
__in LPWSTR argv[]
88
)
99
{
10+
DWORD er = ERROR_SUCCESS;
1011
HRESULT hr = S_OK;
11-
DWORD dwExitCode = 0;
1212
LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL;
1313
LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL;
14-
LPCWSTR wzBadFile = argc > 3 ? argv[3] : NULL;
14+
LPCWSTR wzBackupFile = argc > 3 ? argv[3] : NULL;
1515

16-
if (argc != 4)
16+
if (!wzDestinationFile || !*wzDestinationFile || !wzGoodFile || !*wzGoodFile)
1717
{
1818
ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args");
1919
}
2020

21-
if (!::MoveFileW(wzDestinationFile, wzBadFile))
21+
if (wzBackupFile && *wzBackupFile && !::CopyFileW(wzDestinationFile, wzBackupFile, FALSE))
2222
{
23-
ExitWithLastError(hr, "Failed to move bad file");
23+
er = ::GetLastError();
24+
if (ERROR_PATH_NOT_FOUND != er && ERROR_FILE_NOT_FOUND != er)
25+
{
26+
ExitOnWin32Error(er, hr, "Failed to copy to backup file");
27+
}
2428
}
2529

26-
if (!::MoveFileW(wzGoodFile, wzDestinationFile))
30+
if (!::CopyFileW(wzGoodFile, wzDestinationFile, FALSE))
2731
{
28-
ExitWithLastError(hr, "Failed to move good file");
32+
ExitWithLastError(hr, "Failed to copy in good file");
2933
}
3034

3135
LExit:
32-
return FAILED(hr) ? (int)hr : (int)dwExitCode;
36+
return FAILED(hr) ? (int)hr : (int)0;
3337
}

0 commit comments

Comments
 (0)