Reputation: 2218
I'm developing a Custom Action to install the same file into multiple folders(that are determined at runtime).
The custom action resides inside a Wix C# Custom Action Project. It's code looks like this:
public class CustomActions
{
[CustomAction]
public static ActionResult InstallToTrunks(Session session)
{
// some logic
}
}
The relevant WIX markup looks like this:
<Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.dll' />
<CustomAction Id='InstallToTrunks' BinaryKey='CustomActions' DllEntry='InstallToTrunks' Execute='deferred' Return='check'/>
<InstallExecuteSequence>
<Custom Action='InstallToTrunks' After='InstallInitialize'></Custom>
</InstallExecuteSequence>
However, when I try to run the setup, it fails, and log says: CustomAction InstallToTrunks returned actual error code 1154 (note this may not be 100% accurate if translation happened inside sandbox)
Any help would be very welcome. Alternatively, if you have a suggestion on how to achieve what I'm trying to do(install same file into multiple folders that can be determined only at retuntime) without CustomActions, that would be helpful too.
Thanks.
Upvotes: 3
Views: 2971
Reputation: 32270
Although you accepted the answer and it seems that you'll go the custom action way, I would point your attention that CopyFile approach is the recommended and supported way of doing this kind of things you describe in your scenario. If you don't know exactly the number of files and locations to copy to, you can add temporary rows to the CopyFile table during install time in an immediate custom action. This way you give Windows Installer exact instructions of what to do and let it do its job.
Upvotes: 3
Reputation: 605
It looks like you're referencing the custom action assembly, rather than the custom action DLL. Those custom action projects produce an unmanaged custom action DLL called xxxx.CA.dll which contains a compressed copy of your custom action assembly and its dependencies.
Try:
<Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.CA.dll' />
Upvotes: 4
Reputation: 21426
WiX already supports this through CopyFile element.
Basically, you create a CopyFile element for each copy you want to make. You can then set the DestinationProperty attribute to a custom property for each copy. These properties can be set dynamically during install.
However, if you want to use a custom action, there are several solutions:
Custom .NET DLLs are not supported. If you have a .NET DLL, convert it to an installer class action.
Upvotes: 3