Closed kipamgs closed 1 month ago
The correct way to get the INSTALLDIR variable (in ElevatedManagedAction ) would be more like this:
session.CustomActionData["INSTALLDIR"]
For now i found another approach that is working:
However it would still be nice if there is a way to access files added with project.AddBinary
in a deffered custom action if that is possible with wix. I guess this is not possible because deffered actions are executed in another process?
morning, we had same issue and found our solution in BA Installer. One of our workers share code
[CustomAction]
public static ActionResult ExtractFile(Session session)
{
session.Log("Begin ExtractFile");
// Retrieve the binary stream from the MSI package
var binaryData = session.Database.ExecuteScalar("SELECT `Data` FROM `Binary` WHERE `Name`='MyEmbeddedFile'") as Stream;
if (binaryData != null)
{
// Define the path where the extracted file will be saved
string outputFilePath = Path.Combine(Path.GetTempPath(), "extractedFile.ext");
using (var fileStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
{
binaryData.CopyTo(fileStream);
}
session.Log($"File extracted to {outputFilePath}");
// If needed, execute the extracted file or do something with it
// For example, start the file or use it in further operations
}
else
{
session.Log("Failed to find the embedded binary file.");
return ActionResult.Failure;
}
session.Log("End ExtractFile");
return ActionResult.Success;
}
I'm trying to extract a zip file during the installation problem. I have either one of 2 problems thus the installation fails:
CustomAction.Execute is set to Execute.immediate
The custom action is executed deffered.
Questions:
I am adding the zip and custom action like this: