Reputation: 33
I am creating a wix installer. In some of the wxs file i have defined some properties and i am also creating some session properties inside C# custom action.
Now my requirement is to list out all session properties. So for this i have queried Property table and got all properties that where defined in .wxs file.
For this i have used below custom action:
Microsoft.Deployment.WindowsInstaller.View listBoxView = session.Database.OpenView(string.Format("select * from Property"));
listBoxView.Execute();
while (true)
{
using (Record r = listBoxView.Fetch())
{
if (r == null)
{
break;
}
else
{
Console.WriteLine(r[1].ToString(), r[2].ToString());
}
}
}
}
}
But it does not list out any session property that i have created using c# custom action.
Can someone help me how to list out properties that i created using c# custom action or where these properties get stored?
Thanks much
Upvotes: 1
Views: 2395
Reputation: 17190
Workaround if you REALLY need to enumerate it (requires MSI 4.0 or newer):
Add full logging in the project
<Property Id="MsiLogging" Value="Iwearucmopvx" />
This will log the entire installation process to your %TEMP% folder.
Then get the logfile location with:
var logFile = session["MsiLogFileLocation"];
Since the logfile is locked by the MSI logging you will have to access it in shared mode:
new FileStream(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Read it and get the latest in-memory PROPERTY values by searching out the lines beginning with "PROPERTY CHANGE:".
MSI (c) (90:78) [21:07:16:108]: PROPERTY CHANGE: Adding MsiRunningElevated property. Its value is '1'.
MSI (c) (90:78) [21:07:16:108]: PROPERTY CHANGE: Adding Privileged property. Its value is '1'.
MSI (c) (90:78) [21:07:16:108]: Note: 1: 1402 2: HKEY_CURRENT_USER\Software\Microsoft\MS Setup (ACME)\User Info 3: 2
MSI (c) (90:78) [21:07:16:108]: PROPERTY CHANGE: Adding USERNAME property. Its value is 'Employee'.
MSI (c) (90:78) [21:07:16:108]: Note: 1: 1402 2: HKEY_CURRENT_USER\Software\Microsoft\MS Setup (ACME)\User Info 3: 2
MSI (c) (90!A8) [21:07:30:900]: PROPERTY CHANGE: Modifying WEB_APP_NAME property. Its current value is '$projectname$/v1.0.0'. Its new value: '$projectname$\v1.0.0'.
MSI (c) (90!A8) [21:07:30:901]: PROPERTY CHANGE: Adding WEB_APP_NAME_NORMAL property. Its value is '$projectname$/v1.0.0'.
MSI (c) (90!A8) [21:07:30:901]: PROPERTY CHANGE: Adding WEB_APP_NAME_LAST property. Its value is 'v1.0.0'.
The drawback is that there will always be a log in the %TEMP% folder left over. Maybe add some cleaning up or something.
Upvotes: 0
Reputation: 32270
When you query the property table the way you do in your sample, you get only those properties defined statically in your WiX authoring, and this is expected. At install-time there's a concept called in-memory property collection - this consists out of all the properties defined in various ways: statically in Property table, provided via the command-line, system, defined in custom actions, etc.
You can access all those properties via the Session
object. Just call session[name]
, where name
is the name of the property you're going to get. I doubt there's an enumerator defined for properties, but in real life you rarely need to iterate the properties - you rather try to get a certain one.
Upvotes: 2