I have the following Wix code that should send a property value to Custom Action written in C #. Basically, what I want when MSI is installed, I want to write the path to the folder where Wix installed the program in a text file. I referenced this site and generated the appropriate code, but my custom action does not work.
Below is my wix file:
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="SetupInstallFolder" Language="1033" Version="1.0.0.0" Manufacturer="LP" UpgradeCode="9e10a7d8-4ffb-493c-8318-c44ba4bc0c4c"> <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MediaTemplate /> <Feature Id="ProductFeature" Title="SetupInstallFolder" Level="1"> <ComponentGroupRef Id="ProductComponents" /> </Feature> </Product> <Fragment> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="SetupInstallFolder" /> </Directory> </Directory> </Fragment> <Fragment> <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> <Component Id="SomeRandomEXE"> <File Source ="G:\SarVaGYa\myworkspace\LatestLpa\lpa\lpa_c\here\src\lpa\Release\lpa.exe" /> </Component> </ComponentGroup> <Binary Id="SetupCA2" src="G:\visual studio stuffs\SetupCAInstallFolder\SetupCAInstallFolder\bin\Release\SetupCAInstallFolder.CA.dll"/> <CustomAction Id="INSTALLFOLDERFINDER" Execute="immediate" Property="INSTALLEDPATH" Value="[INSTALLFOLDER]" /> <InstallExecuteSequence> <Custom Action="INSTALLFOLDERFINDER" Sequence="2"></Custom> </InstallExecuteSequence> </Fragment> </Wix>
I also gave my C # code, which should get the value and write it to a file:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Deployment.WindowsInstaller; namespace SetupCAInstallFolder { public class CustomActions { [CustomAction] public static ActionResult InstallFolderFinder(Session session) { session.Log("Here is the SetupCAInstallFolder"); string path = session["INSTALLEDPATH"]; session.Log("Installed Path is " + path); System.IO.File.WriteAllText("F:\\pathgenerated.txt", path);
The Wix file compiles and gives an MSI that does not receive the INSTALLEDPATH value. If I add DllEntry = "InstallFolderFinder" to the CustomAction tag, it fails with an error. The CustomAction / @ DllEntry attribute cannot coexist with the previously specified attribute of this element. A CustomAction element can contain only one of the following target attributes: DllEntry, Error, ExeCommand, JScriptCall, Script, Value, or VBScriptCall
How to pass INSTALLEDPATH value in C # Custom Action?
c # visual-studio-2010 windows-installer wix msiexec
Pant
source share