Reputation: 2364
I have a very weird situation where the custom action code does not run synchronically.
As you in the log can see the "WinRoot dir" log line should appear after "CommonFiles Dir" line. However it appears at the end.
This is the code:
[CustomAction]
public static ActionResult CCCA_LogProductName(Session session)
{
productName = session[InstallShieldConstants.productName];
CustomActionData customActionData = new CustomActionData();
// log properties
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "INSTALLDIR : " +
session[InstallShieldConstants.installDir]);
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "Product Version : " +
session[InstallShieldConstants.productVersion]);
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "Source Dir : " +
session[InstallShieldConstants.sourceDir]);
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "Support Dir : " +
session[InstallShieldConstants.supportDir]);
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "CommonFiles Dir : " +
Environment.GetEnvironmentVariable("CommonProgramFiles"));
CCULog.LogMessageToFile(session, "CCCA_LogProductName", "WinRoot Dir : " +
session[InstallShieldConstants.windowsVolumeDir]);
customActionData.Add(InstallShieldConstants.productName, productName);
session["CCCA_LogProductNameOnFirstTimeInstallStart"] = customActionData.ToString();
session["CCCA_LogProductNameOnUninstallStart"] = customActionData.ToString();
session["CCCA_LogProductNameOnUninstallEnd"] = customActionData.ToString();
session["CCCA_LogProductNameOnInstallStart"] = customActionData.ToString();
session["CCCA_LogProductNameOnInstallEnd"] = customActionData.ToString();
return ActionResult.Success;
}
While the log indicates the following:
Calling custom action CosmoPublisherCustomActions!CosmoPublisherCustomActions.CCUCustomActions.CCCA_LogProductName 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: INSTALLDIR : C:\Program Files (x86)\CosmoCom\Server Components\ 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: Product Version : 7.2.0.119 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: Source Dir : C:\Program Files (x86)\CosmoCom\Server Components\CosmoPublisherHotfixes\HF72-40106\ 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: Support Dir : C:\Users\SVCCOS~1\AppData\Local\Temp{D3407C75-8846-4DB4-8736-149A884053EF} 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: CommonFiles Dir : C:\Program Files (x86)\Common Files MSI (s) (C4!70) [11:24:44:641]: PROPERTY CHANGE: Adding CCCA_LogProductNameOnFirstTimeInstallStart property. Its value is 'ProductName=Media Services .NET'. MSI (s) (C4!70) [11:24:44:642]: PROPERTY CHANGE: Adding CCCA_LogProductNameOnUninstallStart property. Its value is 'ProductName=Media Services .NET'. MSI (s) (C4!70) [11:24:44:642]: PROPERTY CHANGE: Adding CCCA_LogProductNameOnUninstallEnd property. Its value is 'ProductName=Media Services .NET'. MSI (s) (C4!70) [11:24:44:642]: PROPERTY CHANGE: Adding CCCA_LogProductNameOnInstallStart property. Its value is 'ProductName=Media Services .NET'. MSI (s) (C4!70) [11:24:44:642]: PROPERTY CHANGE: Adding CCCA_LogProductNameOnInstallEnd property. Its value is 'ProductName=Media Services .NET'. 07/23/2015 11:24:44 :: CosmoPublisher:: CCCA_LogProductName :: WinRoot Dir : C:\ CustomAction CCCA_LogProductName returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 11:24:44: CCCA_LogProductName. Return value 3. Action ended 11:24:44: INSTALL. Return value 3.
My Installshield custom action is set to 'Synchronous' so I can't understand why its happening. It is weird that custom action that just log to file fails.
Thanks
EDIT:
My log function writes to session log and local file:
/// <summary>
/// Writing message to log file
/// </summary>
/// <param name="tag">tag of the log message.</param>
/// <param name="message">message to write to log.</param>
public static void LogMessageToFile(Session session, string tag, string message)
{
StreamWriter sw = File.AppendText(
GetTempPath() + logFileName);
try
{
string logLine = string.Format(
"{0:G} :: {1} :: {2}", DateTime.Now, tag, message);
sw.WriteLine(logLine);
session.Log("{0:G} :: {1}:: {2} :: {3}", DateTime.Now, logTag, tag, message);
}
finally
{
sw.Close();
}
}
Upvotes: 1
Views: 225
Reputation: 55571
I'm curious why we don't see a stack trace from DTF. DTF allows you to attach a debugger, I'm sure the commands are running in the right order. I've never seen MSI log out of order but it's possible. You could try /l*v! (emphasis on ! ) to see if that makes a difference in the order it's surfaced.
The simplest of CAs can fail. That's why it's important to be a master of them or don't do them at all.
Upvotes: 0