[wix-users] SourceList class in custom actions

Matthias Reuss matthias.mr.reuss at wsa.com
Thu Mar 12 03:03:10 PDT 2020


Hi Bevan,

Yes, my product is already installed (tried both repair and minor upgrade scenarios). SourceList data is available in the registry (HKCR\Installer\Products\<CompressedProductGuid>\SourceList).

Best regards

Matthias

-----Ursprüngliche Nachricht-----
Von: wix-users <wix-users-bounces at lists.wixtoolset.org> Im Auftrag von Bevan Weiss via wix-users
Gesendet: Mittwoch, 11. März 2020 20:50
An: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
Cc: Bevan Weiss <bevan.weiss at gmail.com>
Betreff: Re: [wix-users] SourceList class in custom actions

I believe ProductInstallation is primarily for already installed products.
Based upon the class wrapping this function
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-au%2Fwindows%2Fwin32%2Fapi%2Fmsi%2Fnf-msi-msigetproducti&data=02%7C01%7Cmatthias.mr.reuss%40wsa.com%7C8e0d6d2d45334755784008d7c5f56de5%7C1a41b96d457d41ac94ef22d1901a7556%7C0%7C0%7C637195530208376202&sdata=GdJYn7JDtKpbOQJ8%2F7q6lfNWzBKBSGLLuAxEsSi0Nb4%3D&reserved=0
nfoa?redirectedfrom=MSDN

When your CustomAction is called, is your Product already installed or advertised?

Regards,
Bevan

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Matthias Reuss via wix-users
Sent: 12 March 2020 01:31
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Matthias Reuss <matthias.mr.reuss at wsa.com>
Subject: [wix-users] SourceList class in custom actions

Hello,

I tried to use the SourceList class in a custom action.

As a result, I get exceptions when retrieving Sourcelist items.

To get more into detail, I wrote a custom action like this:

        [CustomAction]
        public static ActionResult GetSourceList(Session session)
        {
                string currentProductCode = session["ProductCode"];

                string productName = session["ProductName"];

                ProductInstallation productInstallInfo = new ProductInstallation(currentProductCode);
                SourceList mySourceList = productInstallInfo.SourceList;

    _logger.Log("SourceList:");
                    try
                    {
                        _logger.Log($"Count: {mySourceList.Count}");
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Exception when retrieving SourceList properties:" + ex.ToString());
                    }
                    try
                    {
                        _logger.Log($"DiskPrompt:
{mySourceList.DiskPrompt}");
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Exception when retrieving SourceList properties:" + ex.ToString());
                    }

[...]

return ActionResult.Success;

        }
    }

and scheduled it after InstallValidate.
This code results in
CustomActionDLL {13:48:9:688}: Exception when retrieving SourceList
properties:System.ArgumentException: The parameter is incorrect.
   at Microsoft.Deployment.WindowsInstaller.SourceList.get_Item(String
property)
   at Microsoft.Deployment.WindowsInstaller.SourceList.get_DiskPrompt()

for the following SourceList attributes:
DiskPrompt
LastUsedSource
LastUsedType
MediaPackagePath
PackageName

and also in an exception when retrieving the Count.

Am I missing something here?
In the documentation, I did not find any restrictions about using the SourceList object or the underlying MsiSourceList* functions in custom action context.

Best regards

Matthias Reuss




____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant
https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.firegiant.com%2F&data=02%7C01%7Cmatthias.mr.reuss%40wsa.com%7C8e0d6d2d45334755784008d7c5f56de5%7C1a41b96d457d41ac94ef22d1901a7556%7C0%7C0%7C637195530208376202&sdata=JIFh6TCJyocWqyE79SAl%2F%2F5qfnrGxC1p%2F8RGYfwOcG4%3D&reserved=0


____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.firegiant.com%2F&data=02%7C01%7Cmatthias.mr.reuss%40wsa.com%7C8e0d6d2d45334755784008d7c5f56de5%7C1a41b96d457d41ac94ef22d1901a7556%7C0%7C0%7C637195530208376202&sdata=JIFh6TCJyocWqyE79SAl%2F%2F5qfnrGxC1p%2F8RGYfwOcG4%3D&reserved=0



More information about the wix-users mailing list