I have a custom action to execute a custom action DLL but it is failing and I believe it's because it does not know how to read the strong name assembly
so I have this:
<Binary Id="StrongName" SourceFile="$(var.MyProject.TargetDir)MyProject.CA.dll"/>
<CustomAction Id="CreateIt"
BinaryKey="StrongName"
DllEntry="Create"
Execute="deferred"
Return="check"
HideTarget="no"
Impersonate="no" />
<CustomAction Id="RemoveIt"
BinaryKey="StrongName"
DllEntry="Remove"
Execute="deferred"
Return="check"
HideTarget="no"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="CreateIt" Before="InstallFinalize">(NOT REMOVE = "ALL")</Custom>
<Custom Action="RemoveIt" Before='InstallFinalize'>(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
So how do I reference the signature as I execute this DLL?
I assume from the *.CA.DLL nomenclature that you are using that this is a DTF custom action. This is a native encapsulated DLL that hosts your managed DLL. Being native, it can't be strong named.
Log the install and look through the log for the reason it is failing.
The solution to my problem was a security issue caused by an obsolete library which is not supported in .NET 4 and it is a different topic so I will not go into detail on it unless someone is curious.
Related
I want to have the installer/uninstaller remove a folder that contains content generated by the application at run time. I figured a Custom Action would be the way to go.
We are using WiX 3.6.
(I want it in the installer sequence for a specific reason that is not important to this question.)
Here is my CustomAction definitions in the xml:
<Binary Id="CustomActionLib" SourceFile="$(var.CustomActionLibrary.TargetDir)$(var.CustomActionLibrary.TargetName).CA.dll" />
<CustomAction Id="DeleteLocalizedCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteLocalized" Return="check" />
<CustomAction Id="DeleteResourcesCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteResources" Return="check" />
Here are my references to them:
<InstallExecuteSequence>
<Custom Action="DeleteLocalizedCA" Before="InstallFiles"/>
<FindRelatedProducts Before="LaunchConditions" />
<RemoveExistingProducts After="InstallFinalize" />
<RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="DeleteLocalizedCA" Before="InstallFiles"/>
<FindRelatedProducts Before="LaunchConditions" />
</InstallUISequence>
I added the CustomActionLibrary project to the solution and added a reference to it from the installer project but it never runs, I never see it in the logs, nothing!
And thus my question, Why Don't my WiX Custom Actions Run?
After several hours of googling and reading (Blog posts, documentation, Stackoverflow, etc.) and testing I finally found a solution that none of my reading pointed to.
I had to put an InstallExecuteSequence to contain my references in a fragment that contained a ComponentGroup:
<Fragment>
<InstallExecuteSequence>
<Custom Action="DeleteLocalizedCA" Before="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>
<ComponentGroup Id='StringsComponents'>
...
</ComponentGroup>
</Fragment>
The Fragment that I had previously put the CustomAction reference in only had steps but no Component or ComponentGroup so apparently doesn't do anything. (I am not the original author of the installer, just taking over for a co-worker who wasn't able to help me on this).
Hopefully this helps others who are struggling with the same issue.
Reading the Wix help I see that "Deferred execution custom actions must come after InstallInitialize and come before InstallFinalize in the action sequence."
However I have to perform a database upgrade on a remote box which needs to be run with the user credentials so I have created an immediate action and set it to run after installFinalize. Subsequently, I need to run another custom action to start a windows service which reads values from the database, this requires elevated (system) permissions, so needs to be a deferred custom action. Which as the Wix help kindly explains to me that I cannot do.
Any help, tips or Wix tricks appreciated please
<CustomAction Id="LaunchServerUpgrade" FileKey="Config.exe" ExeCommand="/upgradeServer"
Return="ignore" Execute="deferred" Impersonate="no"/>
<CustomAction Id="LaunchServerDatabaseUpgrade" FileKey="Config.exe" ExeCommand=" /databaseupgrade"
Return="ignore" Execute="immediate"/>
<CustomAction Id="LaunchServerStartServices" FileKey="Config.exe" ExeCommand=" /startservices"
Return="ignore" Execute="deferred" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="LaunchServerUpgrade" Before='InstallFinalize'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
<Custom Action="LaunchServerDatabaseUpgrade" After='InstallFinalize'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
<Custom Action="LaunchServerStartServices" After='InstallFiles'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
</InstallExecuteSequence>
This question seems to have been answered ad nauseam on this web site but I cannot get Wix to run an exe with Administrator rights (Windows 8.1 64-bit).
The installer I develop copies the prop.exe utility (http://prop.codeplex.com/) to a folder under Program Files (appfolder) as well as a file (my_file.propdesc) which needs to be registered/unregistered by prop.exe like:
prop schema register my_file.propdesc (at the end of installation)
prop schema unregister my_file (at the beginning of uninstallation)
These two command lines need to be run with Administrator privileges. Because these should also be run without a command prompt, I've used CAQuietExec with another CustomAction preparing the argument for CAQuietExec (prop.exe is 32-bit so it's CAQuietExec instead of CAQuietExec64 if I am not mistaken).
<CustomAction Id='PropReg_Prep' Property='PropReg' Value='"[appfolder]prop.exe" schema register "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id='PropUnReg_Prep' Property='PropUnReg' Value='"[appfolder]prop.exe" schema unregister "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id="PropReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
<CustomAction Id="PropUnReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
The custom actions are executed as per:
<InstallExecuteSequence>
<Custom Action="PropReg_Prep" After="CostFinalize" >NOT Installed</Custom>
<Custom Action="PropUnReg_Prep" After="CostFinalize" >Installed</Custom>
<Custom Action="PropUnReg" After="InstallInitialize" >Installed</Custom>
<Custom Action="PropReg" After="InstallFiles" >NOT Installed</Custom>
</InstallExecuteSequence>
I cannot get prop to register/unregister my_file.propdesc. Could someone help?
You are scheduling the actions as Execute='immediate' this runs as the user that executes the installer.
Switch to using Execute='deferred' this will run as the system account. Assuming that the prop.exe doesn't require a full profile to run this should work.
When you're not impersonating you're running with the system account, that's got admin privileges but if you are expecting it to be a user account then there might be issues.
The thing that looks weird to me is that [appfolder]prop.exe for a number of reasons. It doesn't look like a proper application folder, so make sure it's correct. It also needs to be in uppercase, making it a public property, and you should mark it Secure="yes" in the property element. The issue is that it may not get properly transferred from your immediate CA into the execute sequence where it's used.
p.s. Do the install creating a verbose log so you can see how those directory vales are actually being resolved at run time.
I have a custom action
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
My custom action does backup and resolved database. I need to do rollback (drop database) when is canceled installation.
I did:
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="rollback" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
<Custom Action="myActionRollbackId" Before="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
But I was having an error.
If I do like this:
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
<Custom Action="myActionRollbackId" After="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
My custom action myActionRollbackId works.
How to run rolback when is canceled installation?
Someone can help me?
The custom action which runs on install and does something with the database should be deferred (Execute='deferred'). Its corresponding rollback action should be Execute='rollback'. When you schedule these custom actions, the rollback action should go first.
Also, make sure the conditions are set properly.
Installation is always done in transaction. when you launch an installer, it first creates something called installation script which is like a to do list of what it will do while installation.
When we set some custom action as Execute="immediate", it gets executed immediately but when we set our action as Execute="deferred", it gets added in the installation script, hence rollback becomes easy for this.
Now one thing to note here is that we get access to session in Execute="immediate" mode, but we cannot access session in Execute="deferred" mode.
If we try to access session it will give error, which in this case might be the reason for your error...
So I have a custom action
<CustomAction Id="GetTarget"
BinaryKey="CA"
DllEntry="GetTargetPath"
Execute="immediate"
Return="check"
HideTarget="no"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="GetTarget" After="CostFinalize">(NOT REMOVE = "ALL")</Custom>
</InstallExecuteSequence>
This is calling a DLL that calls the method session.GetTargetPath("TARGETPATH"); But I get an exception "The directory name is invalid. TARGETPATH". I have the custom action as After="CostFinalize" as this is what I read from a source (which I can provide) but I think there is a mistake and I think that I just have to to execute the action at the right time.
I think you meant TARGETDIR. Take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/aa371685(v=vs.85).aspx