简体   繁体   中英

WIX - How to Set Properties in Msi when using Custom Bootstrapper WPF UI

I have around 6 to 7 applications consists of websites & windows services to packed into one bundle, for that I have developed Custom UI with WPF bootstrapper application in which i need to take some inputs from the user like virtual directory name, install location, SQL credentials etc.

Now the problem is when i'm trying to set virtual directory name from wpf Ui and passing to msi from bundle by setting through msi property, the property in msi is not updating

Below is my code snippet

In product.wxs i have defined the property and directory structure like below

 <Property Id="TARGETDIRECTORY" Value="test"/>
    <Directory Id='TARGETDIR' Name='SourceDir'>
     <Directory Id="IISROOT" Name='WebDir'>
     <Directory Id='INSTALLDIR'   Name='[TARGETDIRECTORY]'>

In bundle.wxs

<Variable bal:Overridable="yes" Name="TargetDirectory" Value="test"/>
 <MsiPackage Id="TESTSERVER" SourceFile="$(var.Gac.TEST.Setup.Server.TargetPath)" Visible="yes"  DisplayInternalUI="no">
<MsiProperty Name="TARGETDIRECTORY" Value="[TargetDirectory]"/>
       </MsiPackage>

In Bootstraper

engine.StringVariables["TargetDirectory"] = "XYZ";

When i install, virtual directory is creating with name TARGETDIRECTORY instead of xyz. I'm new to wix, can anyone guide me in achieving this and please let me know where i'm doing wrong

I pass some of the properties from cmd , and some i read from xml document and set them.


using (var p = new Process())
                {
                    var info = new ProcessStartInfo
                    {
                        WindowStyle = ProcessWindowStyle.Hidden,
                        FileName = @"C:\Windows\System32\cmd.exe",
                        Arguments = string.Format("/c msiexec /i \"{0}\\{6}.msi\" PATHNAME=\"{0}\" SSLCERTPATH=\"{1}\"" +
                        " MSINEWINSTANCE=1 TRANSFORMS=\":{2}\" USERPATH={3} ENVIRONMENTPATH={4} SSLCERTPASS=\"{5}\" /L*v \"{0}\\{6}Log.txt\""
                        , XmlSettings.EnvironmentFolderPath, FindCertificates.SslCertPath, environment, XmlSettings.IisUserFolderPath,
                        XmlSettings.EnvironmentFolderPath, FindCertificates.SslCertPass, msiName),
                        UseShellExecute = false,
                        CreateNoWindow = true
                    };
                    p.StartInfo = info;
                    p.Start();
                    p.WaitForExit();
                }

Now I'm able to set INSTALLDIR name with custom action.

In custom action, i'm setting required property values from xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM