Skip to content

Commit

Permalink
Add DetectVersionVariable tests
Browse files Browse the repository at this point in the history
Fix publish-nuget condition
  • Loading branch information
nirbar committed Dec 5, 2023
1 parent e7b14a8 commit f599c87
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
path: build/logs/

- name: Publish nuget packages to github
if: ${{ github.event.inputs.publish_nuget == 'true' }} && ${{ github.ref == 'refs/heads/develop-psw-wix' }}
if: github.event.inputs.publish_nuget == 'true' && github.ref == 'refs/heads/develop-psw-wix'
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_PAT }}
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- 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="PanelSwWix4.Sdk">
<PropertyGroup>
<OutputType>Bundle</OutputType>
<InstallerPlatform>x64</InstallerPlatform>
<BA>TestBA_x64</BA>
<UpgradeCode>{5923A558-091E-4015-A9CC-BA92E7A2405A}</UpgradeCode>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TestBA\TestBAWixlib_x64\testbawixlib_x64.wixproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PanelSwWix4.Bal.wixext" />
<PackageReference Include="PanelSwWix4.NetFx.wixext" />
<PackageReference Include="PanelSwWix4.Util.wixext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- 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. -->

<?define ArpId = {4D9EC36A-1E63-4244-875C-3ECB0A2CAE30}?>
<?define ArpKeyPath = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)?>
<?define ArpVersion = 1.0.0.0?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Fragment>
<util:RegistrySearch Bitness="always64" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)" Root="HKLM" Value="DisplayVersion" Variable="TestExeDetectedVersion"/>

<PackageGroup Id="BundlePackages">
<ExePackage Id="TestExe" PerMachine="yes"
InstallArguments="/regw &quot;$(var.ArpKeyPath),DisplayVersion,String,$(var.ArpVersion)&quot; /regw &quot;$(var.ArpKeyPath),QuietUninstallString,String,\&quot;[WixBundleExecutePackageCacheFolder]testexe.exe\&quot; /regd \&quot;$(var.ArpKeyPath)\&quot;&quot;"
DetectVersionVariable="TestExeDetectedVersion" Version="$(var.ArpVersion)">
<PayloadGroupRef Id="TestExePayloads_x64" />
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- 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="PanelSwWix4.Sdk">
<PropertyGroup>
<OutputType>Bundle</OutputType>
<UpgradeCode>{6436F747-08F7-416F-BE92-DB48F282AFC1}</UpgradeCode>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
<ProjectReference Include="..\PackageFail\PackageFail.wixproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PanelSwWix4.Bal.wixext" />
<PackageReference Include="PanelSwWix4.NetFx.wixext" />
<PackageReference Include="PanelSwWix4.Util.wixext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- 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. -->

<?define ArpId = {80E90929-EEA5-48A7-A680-A0237A1CAD84}?>
<?define ArpKeyPath = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)?>
<?define ArpVersion = 1.0.0.0?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Fragment>
<util:RegistrySearch Bitness="always32" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)" Root="HKLM" Value="DisplayVersion" Variable="TestExeDetectedVersion"/>

<PackageGroup Id="BundlePackages">
<ExePackage Id="TestExe" PerMachine="yes"
InstallArguments="/regw &quot;$(var.ArpKeyPath),DisplayVersion,String,$(var.ArpVersion)&quot; /regw &quot;$(var.ArpKeyPath),QuietUninstallString,String,\&quot;[WixBundleExecutePackageCacheFolder]testexe.exe\&quot; /regd \&quot;$(var.ArpKeyPath)\&quot;&quot;"
DetectVersionVariable="TestExeDetectedVersion" Version="$(var.ArpVersion)">

<PayloadGroupRef Id="TestExePayloads" />
</ExePackage>
<MsiPackage Id="PackageFail" SourceFile="$(var.PackageFail.TargetPath)" />
</PackageGroup>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- 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="PanelSwWix4.Sdk">
<PropertyGroup>
<OutputType>Bundle</OutputType>
<UpgradeCode>{799DF604-49CB-4B2C-9FD9-A1C4F93A2FDE}</UpgradeCode>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
<ProjectReference Include="..\PackageTestExe\PackageTestExe.wixproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PanelSwWix4.Bal.wixext" />
<PackageReference Include="PanelSwWix4.NetFx.wixext" />
<PackageReference Include="PanelSwWix4.Util.wixext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- 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. -->

<?define ArpId = {2BE9DAA8-E202-4E42-B25E-B39AA987A59C}?>
<?define ArpKeyPath = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)?>
<?define ArpVersion = 1.0.0.0?>
<?define TestExePath = [ProgramFilesFolder]~Test WiX\$(var.TestGroupName)\PackageTestExe\testexe.exe?>

<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">
<Fragment>
<Variable Name="FAILWHENDEFERRED" bal:Overridable="yes" />
<util:RegistrySearch Bitness="always32" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ArpId)" Root="HKLM" Value="DisplayVersion" Variable="TestExeDetectedVersion"/>

<PackageGroup Id="BundlePackages">
<MsiPackage Id="PackageTestExe" SourceFile="$(var.PackageTestExe.TargetPath)">
<MsiProperty Name="WIXFAILWHENDEFERRED" Value="[FAILWHENDEFERRED]" />
</MsiPackage>
<ExePackage Id="TestExe" PerMachine="yes"
InstallArguments="/regw &quot;$(var.ArpKeyPath),DisplayVersion,String,$(var.ArpVersion)&quot; /regw &quot;$(var.ArpKeyPath),QuietUninstallString,String,\&quot;$(var.TestExePath)\&quot; /regd \&quot;$(var.ArpKeyPath)\&quot;&quot;"
DetectVersionVariable="TestExeDetectedVersion" Version="$(var.ArpVersion)">

<PayloadGroupRef Id="TestExePayloads" />
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
73 changes: 73 additions & 0 deletions src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ public void CanInstallAndUninstallPerMachineArpEntryExePackage()
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}"));
}

[RuntimeFact]
public void CanInstallAndUninstallPerMachineDetectVersionExePackage()
{
var perMachineDetectVersionExePackageBundle = this.CreateBundleInstaller(@"PerMachineDetectVersionExePackage");
var detectVersionExePackage = this.CreateArpEntryInstaller(perMachineDetectVersionExePackageBundle, "TestExe");
var arpId = detectVersionExePackage.ArpId;

Check failure on line 41 in src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs

View workflow job for this annotation

GitHub Actions / Xunit Tests

WixToolsetTest.BurnE2E.ExePackageTests ► CanInstallAndUninstallPerMachineDetectVersionExePackage

Failed test found in: TestResults/WixToolsetTest.BurnE2E.trx Error: System.NullReferenceException : Object reference not set to an instance of an object.
Raw output
System.NullReferenceException : Object reference not set to an instance of an object.
   at WixToolsetTest.BurnE2E.ExePackageTests.CanInstallAndUninstallPerMachineDetectVersionExePackage() in D:\a\wix4\wix4\src\test\burn\WixToolsetTest.BurnE2E\ExePackageTests.cs:line 41

detectVersionExePackage.VerifyRegistered(false);

var installLogPath = perMachineDetectVersionExePackageBundle.Install();
perMachineDetectVersionExePackageBundle.VerifyRegisteredAndInPackageCache();
detectVersionExePackage.VerifyRegistered(true);

Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"TestExe.exe\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},DisplayVersion,String,1.0.0.0\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},QuietUninstallString,String,\\\""));

var uninstallLogPath = perMachineDetectVersionExePackageBundle.Uninstall();
perMachineDetectVersionExePackageBundle.VerifyUnregisteredAndRemovedFromPackageCache();
detectVersionExePackage.VerifyRegistered(false);

Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}"));
}

[RuntimeFact]
public void CanRecacheAndReinstallPerMachineArpEntryExePackageOnUninstallRollback()
{
Expand Down Expand Up @@ -67,6 +89,40 @@ public void CanRecacheAndReinstallPerMachineArpEntryExePackageOnUninstallRollbac
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"TestExe.exe\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},DisplayVersion,String,1.0.0.0\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},QuietUninstallString,String,\\\""));
}

[RuntimeFact]
public void CanRecacheAndReinstallPerMachineDetectVersionExePackageOnUninstallRollback()
{
var packageTestExe = this.CreatePackageInstaller("PackageTestExe");
var perMachineDetectVersionExePackageUninstallFailureBundle = this.CreateBundleInstaller(@"PerMachineDetectVersionExePackageUninstallFailure");
var arpEntryExePackage = this.CreateArpEntryInstaller(perMachineDetectVersionExePackageUninstallFailureBundle, "TestExe");
var arpId = arpEntryExePackage.ArpId;

Check failure on line 98 in src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs

View workflow job for this annotation

GitHub Actions / Xunit Tests

WixToolsetTest.BurnE2E.ExePackageTests ► CanRecacheAndReinstallPerMachineDetectVersionExePackageOnUninstallRollback

Failed test found in: TestResults/WixToolsetTest.BurnE2E.trx Error: System.NullReferenceException : Object reference not set to an instance of an object.
Raw output
System.NullReferenceException : Object reference not set to an instance of an object.
   at WixToolsetTest.BurnE2E.ExePackageTests.CanRecacheAndReinstallPerMachineDetectVersionExePackageOnUninstallRollback() in D:\a\wix4\wix4\src\test\burn\WixToolsetTest.BurnE2E\ExePackageTests.cs:line 98
var testBAController = this.CreateTestBAController();

arpEntryExePackage.VerifyRegistered(false);
packageTestExe.VerifyInstalled(false);

testBAController.SetPackageRequestedCacheType("TestExe", BOOTSTRAPPER_CACHE_TYPE.Remove);

var installLogPath = perMachineDetectVersionExePackageUninstallFailureBundle.Install();
perMachineDetectVersionExePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
arpEntryExePackage.VerifyRegistered(true);
packageTestExe.VerifyInstalled(true);

Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"TestExe.exe\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},DisplayVersion,String,1.0.0.0\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},QuietUninstallString,String,\\\""));

testBAController.ResetPackageStates("TestExe");
testBAController.SetAllowAcquireAfterValidationFailure();

var uninstallLogPath = perMachineDetectVersionExePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1");
perMachineDetectVersionExePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
arpEntryExePackage.VerifyRegistered(true);
packageTestExe.VerifyInstalled(true);

Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: TestExe, default: None, requested: Acquire"));
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}"));
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"TestExe.exe\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},DisplayVersion,String,1.0.0.0\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},QuietUninstallString,String,\\\""));
}

[RuntimeFact]
public void CanReinstallPerMachineArpEntryExePackageOnUninstallRollback()
{
Expand Down Expand Up @@ -142,6 +198,23 @@ public void CanUninstallPerMachineArpEntryExePackageOnInstallRollback()
Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}"));
}

[RuntimeFact]
public void CanUninstallPerMachineDetectVersionExePackageOnInstallRollback()
{
var perMachineDetectVersionExePackageFailureBundle = this.CreateBundleInstaller(@"PerMachineDetectVersionExePackageFailure");
var arpEntryExePackage = this.CreateArpEntryInstaller(perMachineDetectVersionExePackageFailureBundle, "TestExe");
var arpId = arpEntryExePackage.ArpId;

Check failure on line 206 in src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs

View workflow job for this annotation

GitHub Actions / Xunit Tests

WixToolsetTest.BurnE2E.ExePackageTests ► CanUninstallPerMachineDetectVersionExePackageOnInstallRollback

Failed test found in: TestResults/WixToolsetTest.BurnE2E.trx Error: System.NullReferenceException : Object reference not set to an instance of an object.
Raw output
System.NullReferenceException : Object reference not set to an instance of an object.
   at WixToolsetTest.BurnE2E.ExePackageTests.CanUninstallPerMachineDetectVersionExePackageOnInstallRollback() in D:\a\wix4\wix4\src\test\burn\WixToolsetTest.BurnE2E\ExePackageTests.cs:line 206

arpEntryExePackage.VerifyRegistered(false);

var installLogPath = perMachineDetectVersionExePackageFailureBundle.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);
perMachineDetectVersionExePackageFailureBundle.VerifyUnregisteredAndRemovedFromPackageCache();
arpEntryExePackage.VerifyRegistered(false);

Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"TestExe.exe\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},DisplayVersion,String,1.0.0.0\" /regw \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId},QuietUninstallString,String,\\\""));
Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}"));
}

[RuntimeFact]
public void CanUseLargeCustomExitCode()
{
Expand Down

0 comments on commit f599c87

Please sign in to comment.