Let’s say I have this directory structure.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="test" Name="test">
<Component Id="file" Guid="*">
<File Id="file" Source="file.dll"></File>
</Component>
</Directory>
</Directory>
This will install file.dll into C:\test. What I want to do is during the install overwrite where that file directory with C:\newpath\ and install the file there instead. I have tried this with a Custom Action with no luck. I do see the debug line written so I know it’s being called, it’s just the file is still installed in C:\test
<InstallExecuteSequence>
<Custom Action="OverwriteDir" After="CostFinalize" />
</InstallExecuteSequence>
[CustomAction]
public static ActionResult OverwriteDir(Session session)
{
System.Diagnostics.Debug.WriteLine(session["tester"]);
session["tester"] = "C:\\newpath";
return ActionResult.Success;
}
What can I do differently?
First you need to make sure that the folder which contains your file inside the MSI uses a public installer property (no lowercase letters in its name) as its ID. The best solution is TARGETDIR because its already configured.
After that, you can use one of these custom action to change the property value during install: