n13org / WixToolset-Tutorials

A collection of tutorials for the Wix Toolset, which include a bunch of samples and examples
MIT License
19 stars 4 forks source link

DotNetCompatibilityCheck not working in my Setup #10

Closed MyKeySoftMK closed 1 day ago

MyKeySoftMK commented 1 week ago

I try to use the detection of Microsoft.WindowsDesktop.App 8.0.x

In my product.wxs (WiX5.0.1) i have following code:


    <netfx:DotNetCompatibilityCheck
            Platform="x64"
            Property="DOTNETCHECKRESULT"
            RollForward="latestPatch"
            RuntimeType="desktop"
            Version="8.0.0" />

    <!-- UI-Dialogs -->
    <UIRef Id="WixUI_KargWareFeatureTree" />
    <!-- Prerequisites -->
    <SetProperty Id="PreReg1FoundText" Value=".NET Desktop Runtime 8.0" Before="AppSearch" />
    <SetProperty Id="PREREG1CONDITION" Value="required" Sequence="ui" Before="LaunchConditions" Condition="(DOTNETCHECKRESULT = 0)" />

But the problem is, that thr condition is not set. I have installed 8.0.10 and testing with "8.0.0 / RollForward="disable"" and "8.0.10 / RollForward="disable""

With the NetCoreCheck-Tool i have following results:

[10/31/24,13:46:29] ============= NetCoreCheck Start ===============
[10/31/24,13:46:29] Found HostFxr: 'C:\Program Files\dotnet\host\fxr\8.0.10\hostfxr.dll'
[10/31/24,13:46:29] Framework Name:      'Microsoft.WindowsDesktop.App'
[10/31/24,13:46:29] Framework Version:   '8.0.0'
[10/31/24,13:46:29] Roll Forward Policy: 'disable'
[10/31/24,13:46:29] Temporary runtime config file path: 'D:\_AppDev\VS2022\KMFCore\Tools\Test35142906.runtimeconfig.json'.
[10/31/24,13:46:29] Temp runtime config file text: '{ "runtimeOptions": { "rollForward": "disable", "framework": { "name": "Microsoft.WindowsDesktop.App", "version": "8.0.0" } } }'.
[10/31/24,13:46:29] Calling hostfxr_initialize_for_runtime_config...
[10/31/24,13:46:29] hostfxr_initialize_for_runtime_config failed: '-2147450730'
[10/31/24,13:46:29] =============  NetCoreCheck End  ===============
[10/31/24,13:46:53] ============= NetCoreCheck Start ===============
[10/31/24,13:46:53] Found HostFxr: 'C:\Program Files\dotnet\host\fxr\8.0.10\hostfxr.dll'
[10/31/24,13:46:53] Framework Name:      'Microsoft.WindowsDesktop.App'
[10/31/24,13:46:53] Framework Version:   '8.0.10'
[10/31/24,13:46:53] Roll Forward Policy: 'disable'
[10/31/24,13:46:53] Temporary runtime config file path: 'D:\_AppDev\VS2022\KMFCore\Tools\Test35167500.runtimeconfig.json'.
[10/31/24,13:46:53] Temp runtime config file text: '{ "runtimeOptions": { "rollForward": "disable", "framework": { "name": "Microsoft.WindowsDesktop.App", "version": "8.0.10" } } }'.
[10/31/24,13:46:53] Calling hostfxr_initialize_for_runtime_config...
[10/31/24,13:46:54] hostfxr_initialize_for_runtime_config succeeded.
[10/31/24,13:46:54] =============  NetCoreCheck End  ===============

Here the log from the msi

...
MSI (c) (3C!A4) [11:26:26:374]: PROPERTY CHANGE: Adding DOTNETCHECKRESULT property. Its value is '0'.
Aktion beendet um 11:26:26: Wix4NetFxDotNetCompatibilityCheck_X64. Rückgabewert 1.
....
Property(C): WixUIRMOption = UseRM
Property(C): PreReg1FoundText = .NET Desktop Runtime 8.0
Property(C): PreReg2FoundText = ----
Property(C): PreReg3FoundText = ----
Property(C): PreReg4FoundText = ----
Property(C): PreReg5FoundText = ----
Property(C): SecureCustomProperties = BURNMSIMODIFY;BURNMSIREPAIR;BURNMSIUNINSTALL;PREREG1CONDITION;PREREG2CONDITION;PREREG3CONDITION;PREREG4CONDITION;PREREG5CONDITION;PREVIOUSFOUND;WIX_DOWNGRADE_DETECTED;WIX_UPGRADE_DETECTED
Property(C): DOTNETCHECKRESULT = 0
Property(C): PreReg1Requiered = 1
Property(C): pr2OK = 1
Property(C): pr3OK = 1
Property(C): pr4OK = 1
Property(C): pr5OK = 1
...
MyKeySoftMK commented 1 week ago

DotNetCompatibilityCheck.zip

Here a sample project to reproduce my problem

MyKeySoftMK commented 4 days ago

Is it possible that the wrong "time" to check is select or what you think?

... Before="AppSearch" />
... Before="LaunchConditions" />

Or what can be the reason that the value is not regnosize?

N7K4 commented 2 days ago

Hi @MyKeySoftMK thanks for the issue report.

I try to help you with the request soon. At the moment I look into your ZIP.

My first impression is, that this condition is wrong.

(DOTNETCHECKRESULT = 0)

because this will be almost everything, false.

You can try the condition "(1 = 0)" or "(1 = 1)" which will always execute to false, or true. So you can be sure that the rest is working. If yes, we can continue investigation in the DOTNET Version detection.

(1 = 1) will mark the checkbox -> condition is true (1 = 0) will uncheck the checkbox -> condition is false

N7K4 commented 2 days ago

BTW.

I removed the project: .\DotNetCompatibilityCheck\DotNetCompatibilityCheck\FxCoreReplaceT4\FxCoreReplaceT4.vbproj from MSI project and dropped MainOutputDir

N7K4 commented 2 days ago

https://wixtoolset.org/docs/schema/netfx/dotnetcompatibilitycheck/ and https://wixtoolset.org/docs/tools/wixext/dotnet/#net-and-net-core

Command to install

msiexec /i C:\de-DE\MYKEYPartner_Setup.msi /l*v installer.log
N7K4 commented 2 days ago

I changed dotnet version to 9.0.0 and got

MSI (c) (EC!CC) [18:15:10:712]: PROPERTY CHANGE: Adding DOTNETRUNTIMECHECK property. Its value is '12290'.

12290 - Required runtime is not installed.

N7K4 commented 2 days ago

With version 8.0.0 I got

MSI (c) (44!8C) [18:18:50:153]: PROPERTY CHANGE: Adding DOTNETRUNTIMECHECK property. Its value is '0'.

0 - Successful compatibility check.

N7K4 commented 2 days ago

This is possible, I need to observe the log files. To be sure that the props are defined, and the timing is correct

MyKeySoftMK commented 2 days ago

You can try the condition "(1 = 0)" or "(1 = 1)" which will always execute to false, or true. So you can be sure that the rest is working. If yes, we can continue investigation in the DOTNET Version detection.

(1 = 1) will mark the checkbox -> condition is true (1 = 0) will uncheck the checkbox -> condition is false

Yes - that is, what i doing now in my rproject.

When I use (0 = 0) then the checkbox is checked. When i use (DOTNETCHECKRESULT = 0) then the checkbox is unchecked.

N7K4 commented 1 day ago

Here the temp solution, which does work for me, I will double check everything and then update the code via Pull Request.

I would be very happy if you can confirm, that the changes are working for you as well. Many thanks, in advance.

TL;DR

To get more details about the behavior of RollForward I raised a question on StackOverflow - WixToolset DotNetCompatibilityCheck - How to use RollForward?

PreRequDlg.wxs

<?xml version="1.0" encoding="utf-8"?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <!--
    ### 0. THIS FILE CAN BE USED AS IT IS. YOU DON'T NEED TO CHANGE IT
    ### **************************************************************
    Source GitHub Gist https://gist.github.com/N7K4/8b146328db03484a61543c4f612c5dd3#file-prerequisitesdlg-wxs
    -->

    <!--
    ### 1. PLEASE ADD THESE TRANSLATION TO ALL OF YOUR WSL FILES
    ### ********************************************************
    <WixLocalization Culture="en-US" Codepage="1252" xmlns="http://schemas.microsoft.com/wix/2006/localization">
      <String Id="PrerequisitesDlg_Title">[ProductName] Setup</String>
      <String Id="PrerequisitesDlgBitmap">WixUI_Bmp_Banner</String>
      <String Id="PrerequisitesDlgTitle">Prerequisites of [ProductName]</String>
      <String Id="PrerequisitesDlgDescription">List and state of prerequisites.</String>
    </WixLocalization>
    -->

    <!-- 
    ### 2. ADD 'PreRegXXXRequiered' AND 'PREREGXXXCONDITION' FROM 1 TO 5 TO YOUR PRODUCT.WXS
    ### ************************************************************************************
    This Dialog supports up to 5 prerequisites.
    The prerequisites can be set as Property with 'PreRegXXXRequiered' as localization text and the Condition 'PREREGXXXCONDITION' (XXX is a value from 1 to 5).
    When the `PreRegXXXRequiered` is not set, the value will be set to 'EmptyPrerequisites' and the field will disappear on the dialog
    -->

    <!-- 
    ### 3. SET LAUNCHCONDITIONS TO YOUR PRODUCT.WXS
    ### *******************************************
    The prerequisites can block the whole installer byusing launch conditions.
    Just use the 'PREREGXXXCONDITION' directly or set the property by a WiX-Variable.
    -->

    <WixVariable Id="EmptyPrerequisites" Value="----" Overridable="no" />

    <Property Id="PREREG1CONDITION" Secure="yes" />
    <Property Id="PREREG2CONDITION" Secure="yes" />
    <Property Id="PREREG3CONDITION" Secure="yes" />
    <Property Id="PREREG4CONDITION" Secure="yes" />
    <Property Id="PREREG5CONDITION" Secure="yes" />

    <Property Id="PreReg1FoundText" Value="!(wix.EmptyPrerequisites)" />
    <Property Id="PreReg2FoundText" Value="!(wix.EmptyPrerequisites)" />
    <Property Id="PreReg3FoundText" Value="!(wix.EmptyPrerequisites)" />
    <Property Id="PreReg4FoundText" Value="!(wix.EmptyPrerequisites)" />
    <Property Id="PreReg5FoundText" Value="!(wix.EmptyPrerequisites)" />

    <SetProperty Id="PreReg1Checked" Value="1" Sequence="ui" Before="CostInitialize" Condition="PREREG1CONDITION" />
    <SetProperty Id="PreReg2Checked" Value="1" Sequence="ui" Before="CostInitialize" Condition="PREREG2CONDITION" />
    <SetProperty Id="PreReg3Checked" Value="1" Sequence="ui" Before="CostInitialize" Condition="PREREG3CONDITION" />
    <SetProperty Id="PreReg4Checked" Value="1" Sequence="ui" Before="CostInitialize" Condition="PREREG4CONDITION" />
    <SetProperty Id="PreReg5Checked" Value="1" Sequence="ui" Before="CostInitialize" Condition="PREREG5CONDITION" />

    <SetProperty Id="PreReg1Requiered" Value="1" Sequence="ui" Before="AppSearch" Condition="PreReg1FoundText &lt;&gt; &quot;!(wix.EmptyPrerequisites)&quot;" />
    <SetProperty Id="PreReg2Requiered" Value="1" Sequence="ui" Before="AppSearch" Condition="PreReg2FoundText &lt;&gt; &quot;!(wix.EmptyPrerequisites)&quot;" />
    <SetProperty Id="PreReg3Requiered" Value="1" Sequence="ui" Before="AppSearch" Condition="PreReg3FoundText &lt;&gt; &quot;!(wix.EmptyPrerequisites)&quot;" />
    <SetProperty Id="PreReg4Requiered" Value="1" Sequence="ui" Before="AppSearch" Condition="PreReg4FoundText &lt;&gt; &quot;!(wix.EmptyPrerequisites)&quot;" />
    <SetProperty Id="PreReg5Requiered" Value="1" Sequence="ui" Before="AppSearch" Condition="PreReg5FoundText &lt;&gt; &quot;!(wix.EmptyPrerequisites)&quot;" />

    <SetProperty Id="pr1OK" Value="1" Sequence="ui" Before="SetAllLauchConditions" Condition="((NOT PreReg1Requiered) OR (PreReg1Requiered AND PreReg1Checked))" />
    <SetProperty Id="pr2OK" Value="1" Sequence="ui" Before="SetAllLauchConditions" Condition="((NOT PreReg2Requiered) OR (PreReg2Requiered AND PreReg2Checked))" />
    <SetProperty Id="pr3OK" Value="1" Sequence="ui" Before="SetAllLauchConditions" Condition="((NOT PreReg3Requiered) OR (PreReg3Requiered AND PreReg3Checked))" />
    <SetProperty Id="pr4OK" Value="1" Sequence="ui" Before="SetAllLauchConditions" Condition="((NOT PreReg4Requiered) OR (PreReg4Requiered AND PreReg4Checked))" />
    <SetProperty Id="pr5OK" Value="1" Sequence="ui" Before="SetAllLauchConditions" Condition="((NOT PreReg5Requiered) OR (PreReg5Requiered AND PreReg5Checked))" />

    <SetProperty Id="AllLauchConditions" Value="1" Sequence="ui" After="CostFinalize" Condition="(pr1OK AND pr2OK AND pr3OK AND pr4OK AND pr5OK)" />

    <UI>
      <Dialog Id="PrerequisitesDlg" Width="370" Height="270" Title="!(loc.PrerequisitesDlg_Title)">
        <Control Id="ProductVersion" Type="Text" X="10" Y="243" Width="56" Height="17" Text="[ProductVersion]" />

        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" DisableCondition="NOT AllLauchConditions" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg" />
        </Control>

        <Control Id="BannerHeader" Type="Text" X="15" Y="6" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.PrerequisitesDlgTitle)" />
        <Control Id="BannerSubHeader" Type="Text" X="15" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.PrerequisitesDlgDescription)" />
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.PrerequisitesDlgBitmap)" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />

        <Control Id="PreReg1" Type="CheckBox" X="20" Y="70" Width="330" Height="18" CheckBoxValue="1" Hidden="yes" Property="PreReg1Checked" Text="[PreReg1FoundText]" Disabled="yes" ShowCondition="PreReg1Requiered" />
        <Control Id="PreReg2" Type="CheckBox" X="20" Y="90" Width="330" Height="18" CheckBoxValue="1" Hidden="yes" Property="PreReg2Checked" Text="[PreReg2FoundText]" Disabled="yes" ShowCondition="PreReg2Requiered" />
        <Control Id="PreReg3" Type="CheckBox" X="20" Y="110" Width="330" Height="18" CheckBoxValue="1" Hidden="yes" Property="PreReg3Checked" Text="[PreReg3FoundText]" Disabled="yes" ShowCondition="PreReg3Requiered" />
        <Control Id="PreReg4" Type="CheckBox" X="20" Y="130" Width="330" Height="18" CheckBoxValue="1" Hidden="yes" Property="PreReg4Checked" Text="[PreReg4FoundText]" Disabled="yes" ShowCondition="PreReg4Requiered" />
        <Control Id="PreReg5" Type="CheckBox" X="20" Y="150" Width="330" Height="18" CheckBoxValue="1" Hidden="yes" Property="PreReg5Checked" Text="[PreReg5FoundText]" Disabled="yes" ShowCondition="PreReg5Requiered" />

      </Dialog>
    </UI>
  </Fragment>
</Wix>

Product.wxs

<!-- Import global variables -->
<?include ProductVariables.wxi ?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" 
     xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx">

  <!--  Erklärungen zum Bereich <Package>  Siehe auch https://wixtoolset.org/docs/schema/wxs/package/

        Id="*" Mit dem + wird erreicht, dass bei jedem erzeugen des Setup eine neue Guid erstellt wird. 
          Man könnte natürlich auch alternativ eine feste Guid vergeben, dass würde dann so ausssehen:
          Id="{2BE1FDE8-FAEE-48B5-AA08-FD2FE26D7FB2}"

        Name="WiXDemoProjekt" Name des Projektes wie es in "Programme und Funktionen" angezeigt wird

        Version="!(bind.FileVersion.MyApplicationFile)" - Das ist die Programmversion des Produktes, 
          entweder man muss die Version manuell angeben: Version="1.0.1.1" oder man kann wie ich es hier
          demonstriere, Binder Variablen des WiX Linker verwenden um Dynamisch die Vesionsnummer aus 
          einer beliebiegen Datei des Projektes zu ermitteln.
          Im Beispiel verwende ich die Möglichkeit die Version welche mit [assembly: AssemblyFileVersion("1.0.0.0")]
          in der AssemblyInfo gesetzt wurde aus der Datei auszulesen.

        Manufacturer="$(var.Manufactor)" Zuweisung des in der Präprozessor Variablen gespeicherten Herstellers, 
          alternativ kann man natürlich auch eine manuelle Zuweiung Manufacturer="Hans-Peter Schelian" vornehmen

        UpgradeCode="$(var.UpgradeGuid)"> Zuweisung der in der Präprozessor Variablen gespeicherten Guid, 
          alternativ kann man die Zuweisung UpgradeCode="{2BE1FDE8-FAEE-48B5-AA08-FD2FE26D7FB2}"> auch manuell 
          durchführen.

        Language="1033" Der Ländercode für die Sprache. Englisch=1033,Deutsch=1031
          siehe auch http://msdn.microsoft.com/en-us/library/bb165625(v=vs.80).aspx -->
  <Package Language="!(loc.LANG)"
       Name="$(var.ProductName)" 
       Version="$(var.ProductVersion)"
       Manufacturer="$(var.Manufacturer)"
       UpgradeCode="$(var.ProductUpgradeCode)" 
       InstallerVersion="200"
       Codepage="1252"  
       ProductCode="$(var.ProductId)" 
       Compressed="yes" 
       UpgradeStrategy="majorUpgrade" 
       ShortNames="no" 
       Scope="perMachine">

    <!-- Erklärungen zum Bereich <Upgrade> 
        Upgrade Id="$(var.UpgradeGuid)"> hier Zuweisung durch Präprozessor Variable, siehe auch Hinweise
          zu define UpgradeGuid

        <UpgradeVersion Minimum="!(bind.FileVersion.MyApplicationFile)" - Hier wird festgestellt ob 
          bereits ein neueres Produkt (Neuere Version) installiert ist.

        <UpgradeVersion Minimum="0.1.0.0" - Prüfung ob bereits eine frühere Version installiert ist

        <UpgradeVersion Minimum="1.0.0.0" Maximum="99.0.0.0" - Ist das Prpdukt in welcher Versio auch immer
            bereits auf dem Rechner installiert, dann wird die interne Variable PREVIOUSVERSIONSINSTALLED gesetzt,
            dadurch wird verhindert, dass selbst dann wenn man eine Version die nicht als Upgrade gilt 
            (nur im vierten Bereich) der Versionsnummer geändert ist, nicht dazu führt, dass es zu doppelten
            Einträgen im Add/Remove Programms kommt.
    -->
    <Upgrade Id="$(var.ProductUpgradeCode)">
      <UpgradeVersion Property="PREVIOUSFOUND"
                            OnlyDetect="yes"
                            Minimum="$(var.ProductVersion)"
                            Maximum="99.0.0.0"
                            IncludeMinimum="no"
                            IncludeMaximum="no"/>
    </Upgrade>

    <!-- Add the MajorUpgrade element (from Wix 3.5.1315.0). To circumnavigate the catch that the MajorUpgrade will disregard changes
         in the revision number of the product version, add the AllowSameVersionUpgrades (or if you prefer AllowDowngrades) attribute.
         This way, you will be able to upgrade from e.g. 1.0.0.7 to 1.0.0.8. and not just from 1.0.7.0 to 1.0.8.0. If you don't do
         this, you may see multiple installations in Programs and Features.-->
    <MajorUpgrade AllowSameVersionUpgrades="yes"
                      Schedule="afterInstallExecute"
                      DowngradeErrorMessage="!(loc.DowngradeError)" />

    <netfx:DotNetCompatibilityCheck
            Property="DOTNETRUNTIMECHECK_8"
            RollForward="major"
            RuntimeType="desktop"
            Platform="x64"
            Version="8.0.0" />
    <netfx:DotNetCompatibilityCheck
            Property="DOTNETRUNTIMECHECK_9"
            RollForward="major"
            RuntimeType="desktop"
            Platform="x64"
            Version="9.0.0" />

    <!-- UI-Dialogs -->
    <UIRef Id="WixUI_KargWareFeatureTree" />
    <!-- Prerequisites -->
    <SetProperty Id="PreReg1FoundText" Value=".NET Desktop Runtime 8.0" Before="AppSearch" />
    <SetProperty Id="PREREG1CONDITION" Value="required" Sequence="ui" After="LaunchConditions" Condition="(DOTNETRUNTIMECHECK_8 = 0)" />
    <SetProperty Id="PreReg2FoundText" Value=".NET Desktop Runtime 9.0" Before="AppSearch" />
    <SetProperty Id="PREREG2CONDITION" Value="required" Sequence="ui" After="LaunchConditions" Condition="(DOTNETRUNTIMECHECK_9 = 0)" />
    <!--<SetProperty Id="PreReg2FoundText" Value="Prerequisites 2 - always not installed" Before="AppSearch" />
    <SetProperty Id="PREREG2CONDITION" Value="required" Sequence="ui" Before="LaunchConditions" Condition="(0 = 1)" />
    <SetProperty Id="PreReg3FoundText" Value="Prerequisites 3" Before="AppSearch" />
    <SetProperty Id="PREREG3CONDITION" Value="required" Sequence="ui" Before="LaunchConditions" Condition="(0 = 1)" />
    <SetProperty Id="PreReg4FoundText" Value="Prerequisites 4" Before="AppSearch" />
    <SetProperty Id="PREREG4CONDITION" Value="required" Sequence="ui" Before="LaunchConditions" Condition="(0 = 1)" />
    <SetProperty Id="PreReg5FoundText" Value="Prerequisites 5" Before="AppSearch" />
    <SetProperty Id="PREREG5CONDITION" Value="required" Sequence="ui" Before="LaunchConditions" Condition="(0 = 1)" />
    -->

    <Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>

  </Package>

</Wix>

Here the image from Orca tool of the UI-Sequence

image

MyKeySoftMK commented 1 day ago

I can confirm that it working now for me too,

Thanks for your investigations

Here a information about RollForward that I found for the NETCoreCheck.exe (the base of the wix-tool):

  3.x NETCoreCheck.exe -n Microsoft.WindowsDesktop.App -v 3.x.0
  3.1.x NETCoreCheck.exe -n Microsoft.WindowsDesktop.App -v 3.1.0
  >=3.0.0 NETCoreCheck.exe -n Microsoft.WindowsDesktop.App -v 3.0.0 -r LatestMajor
  >=5.0.0 < 5.1 NETCoreCheck.exe -n Microsoft.WindowsDesktop.App -v 5.0.0 -r LatestPatch