1
votes

I have a custom action (RunEncryption2) that I'm using for encrypting a configuration file by using aspnet_regiis.exe. The custom action type that I'm using is an EXE with path referencing a directory (initial type 34) using deferred execution in system context (so the final type is 3106). The file that I want to encrypt is on INSTALLDIR, so I have a Set Property custom action (SetRunEncryption2, type 51) where I'm setting RunEncryption2=[INSTALLDIR]. My two custom actions look like this:

SetRunEncryption2

Property Name: RunEncryption2

Property Value: [INSTALLDIR]

RunEncryption2

Working Directory: WindowsFolder

File Name & Command line: [WindowsFolder]Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "[CustomActionData]" -prov "DataProtectionConfigurationProvider"

When the installer runs, I get no error, however the file gets no encryption at all. When I review the log, I get the following:

MSI (s) (34:C0) [17:32:11:356]: Executing op: CustomActionSchedule(Action=RunEncryption2,ActionType=3106,Source=C:\WINDOWS\,Target=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "" -prov "DataProtectionConfigurationProvider",CustomActionData=C:\Test\)

From the log I can see that the CustomActionData property has been set correctly, however it hasn't been included as part of the command.

At this point the only way I have to make the command work is passing a hard-coded value of INSTALLDIR, otherwise it doesn't seem to work.

I have tried:

  1. Not using CustomActionData, instead passing the value of INSTALLDIR as part of my command line directly.
  2. Using a "Path in Property value" custom action with similar results.

When I run option 1 above, I get a 1722 error on the log:

MSI (s) (C4:50) [12:49:46:968]: Note: 1: 1722 2: RunEncryption2 3: C:\WINDOWS\ 4: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider" 
    Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action RunEncryption2, location: C:\WINDOWS\, command: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider"
    MSI (s) (C4:50) [12:49:56:841]: Product: TestEncryption -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action RunEncryption2, location: C:\WINDOWS\, command: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "connectionStrings" "C:\Test\" -prov "DataProtectionConfigurationProvider"

Does anyone know how can I do to correctly execute this command and dynamically pass the value of INSTALLDIR?

1
CustomActionData is only relevant for property retrieval inside the action; running an EXE records its command line arguments during the immediate sequence so your alternate attempt "1" should have worked. What did the log show then? The various EXE types shouldn't be relevant for the command line arguments, so I wouldn't expect "2" to help.Michael Urman
Thanks for your comment, I have updated the question with the result I'm getting on the attempt "1".Juan C. Becerra

1 Answers

0
votes

Finally found the problem was not in the custom action passing the properties, but in the way that aspnet_iisreg is expecting the parameters.

INSTALLDIR is passing the string with a trailing slash (e. gr. c:\Test\), when I hard coded the installation path I was passing c:\Test instead.

The solution consisted in creating another custom action that removes the trailing slash and stores the value in a new property, this then can be used as parameter for aspnet_iisreg.

By the way, as Michael Urman mentioned, there was no need to use CustomActionData. Thanks.