Hi,
Let's assume you have built a .Net assembly custom action DLL that can be ran by both architectures of .NET Runtime (Any CPU build configuration).
Now you may want the above custom action code be executed at install time by your setup package regardless the .NET Runtime architecture (x86 or x64) present on target machine.
In this case the solution is to create a registry search to detect the existing installed architecture of .NET Runtime. Then to create two sibling custom actions: one which will run using as condition the x86 registry search of .Net Runtime and the other which will run using as condition the x64 registry search of .Net Runtime.
This is because our built-in "Call method from .Net assembly custom action" type does not support targeting simultaneously both architectures ("Any CPU') of .NET Runtime. It can either target the x64 architecture or the x86 one.
To implement the above solution into your setup project you should proceed like this:
1. go to "Search" page and create two extended searches like this (lets assume your .NET DLL targets .NET Runtime 7)
Criteria: "Folder sub-folders enumeration contains version"
Folder: [ProgramFiles64Folder]dotnet\shared\Microsoft.WindowsDesktop.App
Minimum: 7.0.0
Search the 64-bit: checked
Criteria: "Folder sub-folders enumeration contains version"
Folder: [ProgramFilesFolder]dotnet\shared\Microsoft.WindowsDesktop.App
Minimum: 7.0.0
Search the 64-bit: unchecked
2. go to "Custom Actions" page and create two duplicate custom actions that will call your .NET DLL and will be conditioned to run only when the x86, respectively x64 version of .NET Runtime is detected
3. save and build your setup project
That is all!
All the best,
Daniel