[wix-users] Wrong Powershell version
Edwin Castro
egcastr at gmail.com
Sat Jul 18 17:59:44 PDT 2020
That Condition sounds like a LaunchCondition. The message is shown and the
installation aborted if the condition is FALSE.
Read it as IF (NOT (Installed OR POWERSHELLVERSION <= "1.0")) THEN
ABORT("[POWERSHELLVERSION]").
Applying a little boolean algebra
IF ((NOT INSTALLED) AND (NOT (POWERSHELLVERSION <= "1.0"))) THEN
ABORT("[POWERSHELLVERSION]").
You want the Condition to be TRUE to continue with the installation.
If you're Installed, then proceed as you're already installed and you need
to repair, uninstal, etc. You'll need to deal with system prereqs no longer
existing though so be mindful of how to proceed. You don't want to get
stuck not being able to uninstall because the system prereq was removed
before your product was.
If you're not Installed, then this is an initial install and you want to
make sure POWERSHELLVERSION is an appropriate version so perhaps your
condition should be POWERSHELL >= "1.0" to proceed.
If you really need the other version then you can do a RegistrySearch for
it like this:
<Property Id="POWERSHELLVERSION3" Secure="yes">
<RegistrySearch Id="PowerShellVersion3Search" Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
Name="PowerShellVersion" Type="raw" />
</Property>
Just make sure you're targeting the oldest version of powershell you can
possibly support.
--
Edwin G. Castro
On Sat, Jul 18, 2020 at 4:29 PM Roberto via wix-users <
wix-users at lists.wixtoolset.org> wrote:
> Hi,
>
> I have the following in my product.wxs to check the installed PSVERSION on
> my machine
>
> // WixPSExtension
> <PropertyRef Id="POWERSHELLVERSION" />
> <Condition Message="[POWERSHELLVERSION]">
> <![CDATA[Installed OR POWERSHELLVERSION <= "1.0"]]>
> </Condition>
>
> During install it shows: 2.0
>
> Get-Host | Select-Object Version gives me:
>
> Version
> -------
> 5.1.18362.752
>
> What is wrong with my XML?
>
> Also I don't understand the condition from above:
>
> 1. Installed - For me it sounds like, if is installed (but in reality it
> executes only if "not installed")
> 2. why `or` ?
>
>
>
>
>
>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
More information about the wix-users
mailing list