WIX database deployment, installation - wix

During my setup I give an option to use "windows authentication" OR "server authetication". Everything works fine and db gets installed as long as I do "server authentication" and provide db userId and password.
What do I need to do in order install db using "windows authentication" (in wix)?
thanks
My product.wxs file:
<Product Id="*" Name="MySetup2" Language="1033" Version="1.0.0.0" Manufacturer="Hewlett-Packard Company" UpgradeCode="bf1da750-c2fe-4026-9d2b-9d291a61a8b5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Binary Id="success_bmp" SourceFile="$(sys.SOURCEFILEDIR)success.bmp" />
<Binary Id="error_bmp" SourceFile="$(sys.SOURCEFILEDIR)error.bmp" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MySetup2" Level="1" ConfigurableDirectory="INSTALLDIR">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id='MvcApp'/>
<ComponentRef Id='SqlComponent' />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Binary Id="CreateTableScript" SourceFile="c:\Temp\MyDb.sql" />
<!-- Specify UI -->
<UIRef Id="MyWebUI" />
<!-- .NET Framework 3.0 SP 1 must be installed -->
<Property Id="FRAMEWORKBASEPATH">
<RegistrySearch Id="FindFrameworkDir" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework" Name="InstallRoot" Type="raw"/>
</Property>
<util:User Id="SQLUser" Name="[DATABASE_USERNAME]" Password="[DATABASE_PASSWORD]" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MySetup2" >
<!--<Component Id="Web.config" Guid="2ED81B77-F153-4003-9006-4770D789D4B6">
<File Id="Web.config" Name="Web.config" Source="$(var.SolutionDir)MvcApplication4\Web.config" DiskId="1" KeyPath="yes" />
<util:XmlFile Id="AppSettingsAddNode" File="[INSTALLDIR]Web.config" Action="createElement" ElementPath="/configuration/appSettings" Name="add" Sequence="1" />
<util:XmlFile Id="AppSettingsKeyAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="key" Value="AddedDuringInstall" Sequence="2" />
<util:XmlFile Id="AppSettingsValueAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="value" Value="This text was added during installation." Sequence="3" />
</Component>
<Directory Id="binFolder" Name="bin">
<Component Id="MvcApplication4.dll" Guid="7FC6DA37-12E5-463d-8E7E-08F73E40CCF2">
<File Id="MvcApplication4.dll" Name="MvcApplication4.dll" Source="$(var.SolutionDir)MvcApplication4\Bin\MvcApplication4.dll" DiskId="1" KeyPath="yes" />
</Component>
</Directory>-->
</Directory>
</Directory>
<Component Id="SqlComponent" Guid="C50999A0-02FD-42d5-9F65-7375318DD328">
<sql:SqlDatabase Id="SqlDatabase"
Database="[DATABASE_NAME]"
Server="[DATABASE_SERVER]"
CreateOnInstall="yes"
DropOnUninstall="yes"
User="SQLUser">
<sql:SqlScript Id="CreateTableScript" ExecuteOnInstall="yes" BinaryKey="CreateTableScript" />
</sql:SqlDatabase>
</Component>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
When I modified this section and removed "User" tag it works using windows authentication. How do I add this tag OR remove it (Condition) based on UI's selection.
<sql:SqlDatabase Id="SqlDatabase"
Database="[DATABASE_NAME]"
Server="[DATABASE_SERVER]"
CreateOnInstall="yes"
DropOnUninstall="yes"
User="SQLUser">

I solved it and created WIX Database Installer like so:
Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
<Product Id="*" Name="MySetup2" Language="1033" Version="1.0.0.0" Manufacturer="Hewlett-Packard Company" UpgradeCode="bf1da750-c2fe-4026-9d2b-9d291a61a8b5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Binary Id="success_bmp" SourceFile="$(sys.SOURCEFILEDIR)success.bmp" />
<Binary Id="error_bmp" SourceFile="$(sys.SOURCEFILEDIR)error.bmp" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MySetup2" Level="1" ConfigurableDirectory="INSTALLDIR">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id='SqlComponent.IntegratedAuthentication' />
<ComponentRef Id='SqlComponent.SQLAuthentication' />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Binary Id="SqlScriptSQLAuthentication" SourceFile="c:\Temp\MyDb.sql" />
<Binary Id="SqlScriptIntegratedAuthentication" SourceFile="c:\Temp\MyDb.sql" />
<!-- .NET Framework 3.0 SP 1 must be installed -->
<Property Id="FRAMEWORKBASEPATH">
<RegistrySearch Id="FindFrameworkDir" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework" Name="InstallRoot" Type="raw"/>
</Property>
<UIRef Id="MyWebUI" />
<util:User Id="SQLUser" Name="[DATABASE_USERNAME]" Password="[DATABASE_PASSWORD]" />
<Property Id='DATABASE_USERNAME'></Property>
<Property Id='DATABASE_PASSWORD'></Property>
<Property Id='DATABASE_NAME'></Property>
<Property Id="DATABASE_SERVER">(local)</Property>
<Property Id="DATABASE_LOGON_TYPE">DatabaseIntegratedAuth</Property>
<Property Id="USEINTEGRATEDSECURITY" Secure="yes"></Property>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="MySetup2" >
</Directory>
</Directory>
<Component Id='SqlComponent.SQLAuthentication' Guid='665D641C-3570-4b96-9CA5-2B4C12594A35' KeyPath='yes'>
<Condition><![CDATA[USEINTEGRATEDSECURITY<>1]]></Condition>
<sql:SqlDatabase Id='SqlDatabase.SQLAuthentication' Database='[DATABASE_NAME]' User='SQLUser' Server='[DATABASE_SERVER]' CreateOnInstall='yes' DropOnUninstall='yes' ContinueOnError='no' />
<sql:SqlScript Id='SqlScriptSQLAuthentication' BinaryKey='SqlScriptSQLAuthentication' SqlDb='SqlDatabase.SQLAuthentication' ExecuteOnInstall='yes' />
</Component>
<Component Id='SqlComponent.IntegratedAuthentication' Guid='E5DF48AE-2338-4029-9FDF-8DAA6AD0216D' KeyPath='yes'>
<Condition>USEINTEGRATEDSECURITY = 1</Condition>
<sql:SqlDatabase Id='SqlDatabase.IntegratedAuthentication' Database='[DATABASE_NAME]' Server='[DATABASE_SERVER]' CreateOnInstall='yes' DropOnUninstall='yes' ContinueOnError='no' />
<sql:SqlScript Id='SqlScriptIntegratedAuthentication' BinaryKey='SqlScriptIntegratedAuthentication' SqlDb='SqlDatabase.IntegratedAuthentication' ExecuteOnInstall='yes' />
</Component>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>
Notice "Condition" operator based on Windows authentication vs. Server authentication.
Custom Action:
namespace CustomActions
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Security.Principal;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.SqlServer.Management.Smo;
using View = Microsoft.Deployment.WindowsInstaller.View;
public static class CustomActions
{
#region Public Methods and Operators
[CustomAction]
public static ActionResult EnumerateSqlServers(Session session)
{
if (null == session)
{
throw new ArgumentNullException("session");
}
session.Log("EnumerateSQLServers: Begin");
// Check if running with admin rights and if not, log a message to
// let them know why it's failing.
if (false == HasAdminRights())
{
session.Log("EnumerateSQLServers: " + "ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS");
return ActionResult.Failure;
}
ActionResult result;
DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
DataRow[] rows = dt.Select(string.Empty, "IsLocal desc, Name asc");
result = EnumSqlServersIntoComboBox(session, rows);
session.Log("EnumerateSQLServers: End");
return result;
}
[CustomAction]
public static ActionResult VerifySqlConnection(Session session)
{
try
{
//Debugger.Break();
session.Log("VerifySqlConnection: Begin");
var builder = new SqlConnectionStringBuilder
{
DataSource = session["DATABASE_SERVER"],
InitialCatalog = "master",
ConnectTimeout = 5
};
if (session["DATABASE_LOGON_TYPE"] != "DatabaseIntegratedAuth")
{
builder.UserID = session["DATABASE_USERNAME"];
builder.Password = session["DATABASE_PASSWORD"];
}
else
{
builder.IntegratedSecurity = true;
}
using (var connection = new SqlConnection(builder.ConnectionString))
{
if (connection.CheckConnection(session))
{
session["ODBC_CONNECTION_ESTABLISHED"] = "1";
}
else
{
session["ODBC_CONNECTION_ESTABLISHED"] = string.Empty;
}
}
session.Log("VerifySqlConnection: End");
}
catch (Exception ex)
{
session.Log("VerifySqlConnection: exception: {0}", ex.Message);
throw;
}
return ActionResult.Success;
}
#endregion
#region Methods
private static ActionResult EnumSqlServersIntoComboBox(Session session, IEnumerable<DataRow> rows)
{
try
{
//Debugger.Break();
session.Log("EnumSQLServers: Begin");
View view = session.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='DATABASE_SERVER'");
view.Execute();
view = session.Database.OpenView("SELECT * FROM ComboBox");
view.Execute();
Int32 index = 1;
session.Log("EnumSQLServers: Enumerating SQL servers");
foreach (DataRow row in rows)
{
String serverName = row["Name"].ToString();
// Create a record for this web site. All I care about is
// the name so use it for fields three and four.
session.Log("EnumSQLServers: Processing SQL server: {0}", serverName);
Record record = session.Database.CreateRecord(4);
record.SetString(1, "DATABASE_SERVER");
record.SetInteger(2, index);
record.SetString(3, serverName);
record.SetString(4, serverName);
session.Log("EnumSQLServers: Adding record");
view.Modify(ViewModifyMode.InsertTemporary, record);
index++;
}
view.Close();
session.Log("EnumSQLServers: End");
}
catch (Exception ex)
{
session.Log("EnumSQLServers: exception: {0}", ex.Message);
throw;
}
return ActionResult.Success;
}
private static bool HasAdminRights()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
private static bool CheckConnection(this SqlConnection connection, Session session)
{
try
{
if (connection == null)
{
return false;
}
connection.Open();
var canOpen = connection.State == ConnectionState.Open;
connection.Close();
return canOpen;
}
catch (SqlException ex)
{
session["ODBC_ERROR"] = ex.Message;
return false;
}
}
#endregion
}
}
MyWebUI.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<EnsureTable Id='ComboBox'/>
<!--The custom action DLL itself.-->
<Binary Id="WebAppCA"
SourceFile="C:\Temp\MvcApplication4a\CustomActions\bin\Debug\CustomActions.CA.dll" />
<!--The custom action to enumerate the web sites and app pools into the
appropriate combo boxes.-->
<CustomAction Id="EnumerateSqlServers"
BinaryKey="WebAppCA"
DllEntry="EnumerateSqlServers"
Execute="immediate"
Return="check" />
<CustomAction Id="VerifySqlConnection"
BinaryKey="WebAppCA"
DllEntry="VerifySqlConnection"
Execute="immediate"
Return="check" />
<!--Make sure the enumerate web sites and app pools custom action gets
called, but only called if we are doing and install.-->
<InstallUISequence>
<Custom Action="EnumerateSqlServers"
After="CostFinalize"
Overridable="yes">NOT Installed</Custom>
</InstallUISequence>
<!-- MyWeb UI -->
<UI Id="MyWebUI">
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<!-- Injection of custom UI. -->
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="DatabaseInformationDlg">LicenseAccepted = "1"</Publish>
</UI>
</Fragment>
</Wix>
UIDialogs.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<!--Define the dialog to get the Server and Database name information from the user-->
<Dialog Id="DatabaseInformationDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
<Control Id="ServerLabel" Type="Text" X="20" Y="62" Width="80" Height="25" NoPrefix="yes" Text="SQL Database:" />
<Control Id="Server" Type="ComboBox" Height="16" Width="180" X="110" Y="60" Property="DATABASE_SERVER">
<ComboBox Property="DATABASE_SERVER">
<ListItem Text="[DATABASE_SERVER]" Value="[DATABASE_SERVER]" />
</ComboBox>
<Publish Property="LOGON_VALID" Value="0">1</Publish>
</Control>
<Control Id="DatabaseType" Type="RadioButtonGroup" X="20" Y="100" Width="290" Height="40" Property="DATABASE_LOGON_TYPE">
<RadioButtonGroup Property="DATABASE_LOGON_TYPE">
<RadioButton Value="DatabaseIntegratedAuth" X="0" Y="0" Width="290" Height="16" Text="Trusted (Windows Authentication)" />
<RadioButton Value="DatabaseAccount" X="0" Y="20" Width="290" Height="16" Text="Specify Username and Password (SQL Authentication)" />
</RadioButtonGroup>
</Control>
<!-- Login -->
<Control Type="Text" Id="UsernameLabel" Width="50" Height="15" X="40" Y="150" Text="&Login:">
<Condition Action="disable"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Condition>
<Condition Action="enable"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Condition>
</Control>
<Control Id="Username" Type="Edit" X="110" Y="145" Width="180" Height="18" Property="DATABASE_USERNAME" Text="{80}">
<Condition Action="disable"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Condition>
<Condition Action="enable"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Condition>
<Publish Property="LOGON_VALID" Value="0">1</Publish>
</Control>
<!-- Password -->
<Control Type="Text" Id="PasswordLabel" Width="50" Height="15" X="40" Y="173" Text="&Password:">
<Condition Action="disable"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Condition>
<Condition Action="enable"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Condition>
</Control>
<Control Id="Password" Type="Edit" X="110" Y="170" Width="180" Height="18" Property="DATABASE_PASSWORD" Text="{80}" Password="yes" >
<Condition Action="disable"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Condition>
<Condition Action="enable"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Condition>
</Control>
<Control Id="Test" Type="PushButton" X="40" Y="197" Width="100" Height="17" Text="Test Connection">
<Condition Action="disable"><![CDATA[DATABASE_SERVER = ""]]></Condition>
<Condition Action="enable"><![CDATA[DATABASE_SERVER <> ""]]></Condition>
<!--test connection-->
<Publish Property="ODBC_SERVER" Value="[DATABASE_SERVER]" Order="1">1</Publish>
<Publish Property="ODBC_SERVER" Value="[ComputerName]" Order="1"><![CDATA[DATABASE_SERVER = "(local)"]]></Publish>
<Publish Property="ODBC_CONNECTION_STRING" Value="Driver=SQL Server;Server=[ODBC_SERVER],1433;Uid=[DATABASE_USERNAME];Pwd=[DATABASE_PASSWORD]" Order="2">1</Publish>
<Publish Event="DoAction" Value="VerifySqlConnection" Order="3">1</Publish>
<Publish Property="LOGON_VALID" Value="1" Order="4"><![CDATA[ODBC_CONNECTION_ESTABLISHED]]></Publish>
<Publish Property="LOGON_VALID" Value="0" Order="4"><![CDATA[NOT ODBC_CONNECTION_ESTABLISHED]]></Publish>
<Publish Property="LOGON_ERROR" Value="Unexpected Error" Order="4"><![CDATA[(NOT ODBC_CONNECTION_ESTABLISHED) AND (ODBC_ERROR = "")]]></Publish>
<Publish Property="LOGON_ERROR" Value="[ODBC_ERROR]" Order="4"><![CDATA[NOT ODBC_CONNECTION_ESTABLISHED]]></Publish>
<Publish Event="SpawnDialog" Value="InvalidLogonDlg" Order="5"><![CDATA[NOT ODBC_CONNECTION_ESTABLISHED]]></Publish>
</Control>
<Control Id="TestResult_Success" Type="Bitmap" X="210" Y="10" Width="24" Height="24" Text="success_bmp">
<Condition Action="hide"><![CDATA[LOGON_VALID <> 1]]></Condition>
<Condition Action="show"><![CDATA[LOGON_VALID = 1]]></Condition>
</Control>
<Control Id="TestResult_Failure" Type="Bitmap" X="210" Y="10" Width="24" Height="24" Text="error_bmp">
<Condition Action="hide"><![CDATA[LOGON_VALID = 1]]></Condition>
<Condition Action="show"><![CDATA[LOGON_VALID <> 1]]></Condition>
</Control>
<!-- Back button -->
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next">
<Publish Property="DATABASE_LOGON_TYPE" Value="[DATABASE_LOGON_TYPE]">1</Publish>
<Publish Property="DATABASE_SERVER" Value="[DATABASE_SERVER]">1</Publish>
<Publish Property="DATABASE_USERNAME" Value="[DATABASE_USERNAME]"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Publish>
<Publish Property="DATABASE_PASSWORD" Value="[DATABASE_PASSWORD]"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Publish>
<Publish Property="DATABASE_USERNAME"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Publish>
<Publish Property="DATABASE_PASSWORD"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Publish>
<Publish Property="USEINTEGRATEDSECURITY" Value="0"><![CDATA[DATABASE_LOGON_TYPE = "DatabaseAccount"]]></Publish>
<Publish Property="USEINTEGRATEDSECURITY" Value="1"><![CDATA[DATABASE_LOGON_TYPE <> "DatabaseAccount"]]></Publish>
<Condition Action="disable"><![CDATA[LOGON_VALID <> 1]]></Condition>
<Condition Action="enable"><![CDATA[LOGON_VALID = 1]]></Condition>
<Publish Event="NewDialog" Value="DatabaseNameDlg">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter a SQL instance and database name.</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}SQL instance and database information.</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
<!-- INVALIDE SQL LOGIN -->
<Dialog Id="InvalidLogonDlg" Width="260" Height="105" Title="Invalid Logon">
<Control Id="Return" Type="PushButton" X="102" Y="77" Width="56" Height="17" Default="yes" Cancel="yes" Text="OK">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="50" Text="[ODBC_ERROR]" />
<Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" FixedSize="yes" IconSize="32" Text="WixUI_Ico_Exclam" />
</Dialog>
<!-- DATABASE NAME -->
<Dialog Id="DatabaseNameDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
<!-- Connection String -->
<Control Id="DatabaseStringLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="Database name:" />
<Control Id="DatabaseStringEdit" Type="Edit" X="45" Y="90" Width="220" Height="18" Property="DATABASE_NAME" Text="{100}" />
<Control Id="DatabaseStringLabel123" Type="Text" X="45" Y="120" Width="100" Height="15" TabSkip="no" Text="Use Win: [USEINTEGRATEDSECURITY]--" />
<!-- Back button -->
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="DatabaseInformationDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next">
<Publish Event="NewDialog" Value="CustomizeDlg">
<!--if settings are correct, allow next dialog-->
<![CDATA[DATABASE_NAME <> ""]]>
</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter database configuration</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Database Settings</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>
OUTPUT:
a working db installer:

See: SqlDatabase Element (Sql Extension)
Remarks
The User attribute references credentials specified in a User element.
If a user is not specified then Windows Authentication will be used by
default using the credentials of the user performing the install to
execute sql strings, etc.

Related

To validate the input controls in WIX Installer

I'm new to WIX. I wanted to validate the input controls like Textbox is not null and password and confirm password is same.
I tried to do it in the custom action,but i couldn't send the parameters.
If at all i send the parameter how to the return the values with the to stay in the same installation page.
<Dialog Id="XXX" Width="370" Height="270" Title="Installation">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" >
<Publish Event="DoAction" Value="CheckingPID">1</Publish>
<Publish Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
<Control Id="Usernamelbl" Type="Text" X="20" Y="100" Width="95" Height="10" NoPrefix="yes" Property="WIXUI_INSTALLDIR" Text="Username:" />
<Control Id="UsernameVal" Type="Edit" X="125" Y="100" Width="200" Height="17" Property="SETUSERNAME" Indirect="no" Disabled="no" />
</Dialog>
<CustomAction Id="CheckingPID" BinaryKey="CustomActionBinary" Impersonate="no" DllEntry="Validate" Execute="immediate" Return="check"/>
[CustomAction]
public static ActionResult Validate(Session session)
{
MessageBox.Show(Session.CustomActionData["SETUSERNAME"]);
return ActionResult.Success;
}
Is this the right way to validate or any other way to validate.
Thanks in advance
Here is a Working Custom Wix Dialog
This code creates a custom UI Dialog with Custom Actions. Purpose of this Dialog is while we are installing a Desktop Application we can setup Db Connection information.
DbConnectionInfo.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Property Id="Server" Value="127.0.0.1" />
<Property Id="Port" Value="XXX" />
<Property Id="Database" Value="DbName" />
<Property Id="User" Value="root" />
<Property Id="Password" Value="1234abcA" />
<UI Id="DbConnectionDlgUI">
<Dialog Id="DbConnectionDlg" Width="400" Height="275" Title="Demo : Database Connection Settings">
<Control Id="headerText" Type="Text" X="140" Y="10" Width="260" Height="40" Transparent="no"
Text="{\WixUI_Font_Title}Database Connection Settings Screen" />
<Control Id="SideBar" Type="Bitmap" Text="WixUIBannerBmp" X="0" Y="0" Height="240" Width="130" Image="yes" />
<Control Id="explanationText" X="140" Y="50" NoWrap="no" RightAligned="no" Transparent="yes"
Type="Text" Width="260" Height="100"
Text="{\WixUI_Font_Normal}Before you can use this Service, you need to provide your My Sql Connection settings which is used getting the email database information. If you choose not to install this application, click on the Cancel button to exit." />
<Control Id="ServerLabel" Type="Text" X="160" Y="120" Height="17" Width="65" Transparent="yes" Text="{\WixUI_Font_Normal}Server:" />
<Control Id="ServerTextBox" Type="Edit" X="230" Y="120" Height="17" Width="60" Property="Server" />
<Control Id="PortLabel" Type="Text" X="295" Y="120" Height="17" Width="21" Transparent="yes" Text="{\WixUI_Font_Normal}Port:" />
<Control Id="PortTextBox" Type="Edit" X="325" Y="120" Height="17" Width="30" Property="Port" />
<Control Id="DatabaseLabel" Type="Text" X="160" Y="140" Height="17" Width="65" Transparent="yes" Text="{\WixUI_Font_Normal}Database:" />
<Control Id="DatabaseTextbox" Type="Edit" X="230" Y="140" Height="17" Width="120" Property="Database" />
<Control Id="UserLabel" Type="Text" X="160" Y="160" Height="17" Width="65" Transparent="yes" Text="{\WixUI_Font_Normal}User:" />
<Control Id="UserTextbox" Type="Edit" X="230" Y="160" Height="17" Width="120" Property="User" />
<Control Id="PasswordLabel" Type="Text" X="160" Y="180" Height="17" Width="65" Transparent="yes" Text="{\WixUI_Font_Normal}Password:" />
<Control Id="PasswordTextbox" Type="Edit" X="230" Y="180" Height="17" Width="120" Property="Password" Password="yes"/>
<Control Id="bottomLine" Type="Line" X="130" Y="239" Width="270" Height="1"/>
<Control Id="Back" Type="PushButton" Text="Back" X="208" Y="248" Height="17" Width="60" >
</Control>
<Control Id="Next" Type="PushButton" Text="Next" X="269" Y="248" Height="17" Width="60" Default="yes">
<Publish Event="DoAction" Value="CreateDbConnectionProperties">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" Text="Cancel" X="330" Y="248" Height="17" Width="60" Cancel="yes">
<Publish Event="DoAction" Value="CleanUpAction">1</Publish>
<Publish Event="NewDialog" Value="CancelDlg" Order="2">1</Publish>
</Control>
</Dialog>
</UI>
</Fragment>
<Fragment>
<CustomAction Id="CreateDbConnectionProperties" BinaryKey="CustomActionBinary" DllEntry="CreateDbConnectionProperties" />
</Fragment>
</Wix>
CustomAction.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.IO;
namespace Demo.InstallerActions
{
public class CustomlActions
{
private readonly static string AppName = "Demo";
[CustomAction]
public static ActionResult CreateDbConnectionProperties(Session session)
{
session.Log("Saving Db Details Started.");
try
{
string Server = session["Server"].Encrypt(AppConstants.SecurityKey,true);
string Database = session["Database"].Encrypt(AppConstants.SecurityKey, true);
string User = session["User"].Encrypt(AppConstants.SecurityKey, true);
string Password = session["Password"].Encrypt(AppConstants.SecurityKey, true);
string Port = session["Port"].Encrypt(AppConstants.SecurityKey, true);
string[] confData = { Server, Database, User, Password, Port };
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
if (!Directory.Exists($"{appdataPath}\\{AppName}"))
{
Directory.CreateDirectory($"{appdataPath}\\{AppName}");
}
File.WriteAllLines($"{appdataPath}\\{AppName}\\conf.sys", confData);
session.Log("Db Details Saved");
return ActionResult.Success;
}
catch (Exception ex)
{
session.Log($"Configuration File Creation Failed with Error: {ex.Message}");
return ActionResult.Failure;
}
}
[CustomAction]
public static ActionResult CleanUpAction(Session session)
{
session.Log("Cleanup Started.");
try
{
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
if (!Directory.Exists($"{appdataPath}\\{AppName}"))
Directory.Delete($"{appdataPath}\\{AppName}", true);
session.Log("Db Details Saved");
return ActionResult.Success;
}
catch (Exception ex)
{
session.Log($"Cleanup Error: {ex.Message}");
return ActionResult.Failure;
}
}
}
}

Wix prorperies value don't value is not changed after radioButton section

I want to select in the office version, the default is 32 bits. But when being installed and checked the properties to copy files, select the default value, without considering my choice. How to fix it?
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
>
<Product Id="{95B5E9E1-AB21-4947-A047-74C169B1D1F2}" Name="Xproduct" Language="1033" Version="1.0.0.0" Manufacturer="X Limited" UpgradeCode="af9969f2-fb9c-44c7-b207-e89f1d900a91">
<Package InstallerVersion="301" Compressed="yes" InstallPrivileges="elevated" InstallScope="perMachine" AdminImage="yes" Manufacturer="X Limited" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Property Id="officeVersion" Value="32"/>
<UI Id="MyWebUI">
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<DialogRef Id="CheckVersion"/>
<Publish Dialog="LicenseAgreementDlg" Control="Next"
Event="NewDialog" Value="CheckVersion"
Order="3">LicenseAccepted = "1"</Publish>
</UI>
<Feature Id="CommonFuture" Title="xInstaller" Level="1">
<ComponentGroupRef Id="ShotcutComponents"/>
<ComponentGroupRef Id="xComponents"/>
<ComponentGroupRef Id="PocketSoapComponent"/>
<ComponentGroupRef Id="SystemComponentsWinX86" />
<ComponentGroupRef Id="SystemComponentsWinX64"/>
<ComponentGroupRef Id="SystemComponentsWinX64Office64"/>
</Feature>
</Product>
<Fragment>
<Condition Message="You need to be an administrator to install this product.">
Privileged
</Condition>
</Fragment>
<Fragment>
<InstallExecuteSequence>
<Custom Action='MyProcess.TaskKill' Before='InstallValidate'>NOT Installed</Custom>
</InstallExecuteSequence>
<Property Id="System32WindowsFolder" Value="C:\Windows\System32"/>
<Property Id="QtExecCmdLine" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM EXCEL.EXE'/>
<CustomAction Id="MyProcess.TaskKill" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"></CustomAction>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="SystemFolder" />
<Directory Id="System32WindowsFolder"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="xAddin"/>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="xShorcutsDir" Name="xAddin"/>
</Directory>
<Directory Id="AppDataFolder">
<Directory Id="Microsoft" Name="Microsoft">
<Directory Id="AddIns" Name="AddIns"/>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="SystemComponentsWinX64" Directory="SystemFolder">
<Component Id="SystemDLL" Guid="{5CC58B1B-CF05-412B-A9DC-89C4D9DDA8E3}" >
<File Id="FILE_xXIDLL" Source="dll/system/xXlFunctions.dll" KeyPath="yes"/>
<Condition>officeVersion = 32 AND %PROCESSOR_ARCHITECTURE="AMD64"</Condition>
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="SystemComponentsWinX86" Directory="SystemFolder">
<Component Id="SystemDLLx86" Guid="{8F3B689F-EC06-43C9-AF87-47DB8534EC9D}" >
<File Id="FILE_xXIDLLx86" Source="dll/system/xXlFunctions.dll" KeyPath="yes"/>
<Condition>officeVersion = 32 AND %PROCESSOR_ARCHITECTURE="x86"</Condition>
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="SystemComponentsWinX64Office64" Directory="System32WindowsFolder">
<Component Id="SystemDLLx64" Guid="{569E68EB-9C6D-4B72-A811-429A6901B05A}" >
<File Id="FILE_xXIDLLx64" Source="dll/system/x64/xXlFunctions.dll" KeyPath="yes"/>
<Condition>officeVersion = 64 AND %PROCESSOR_ARCHITECTURE="AMD64"</Condition>
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="xComponents" Directory="AddIns">
<Component Id="xXLA" Guid="{BBDA689A-B48D-4B61-8A9F-50CB0B4BC9AA}" >
<File Id="FILE_xXLA" Source="xla/x.xla"/>
<RegistryValue Id="RegKeyxAddin" Root="HKCU"
Key="Software\Microsoft\Office\Excel\AddIns\aqillaaddin"
Name="xAddin"
Value="x Excel Add-In"
Type="string" KeyPath="yes" />
<RemoveFolder Id="RemoveAddInsFolder" On="uninstall" Directory="AddIns"/>
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="ShotcutComponents" Directory="xShorcutsDir">
<Component Id="UninstallShorcut" Guid="{BEECAC18-779F-4F6A-8D0B-2545626FD80A}">
<Shortcut Id="UninstallShorcut"
Name="Uninstall x Addin"
Description="Uninstall x Addin and all of its components"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]" />
<RemoveFolder Id="RemoveMyApplication" On="uninstall"/>
<RegistryValue Root="HKCU"
Key="Software\Microsoft\xAddin"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
ChecKVersion.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="CheckVersion" Width="370" Height="270" Title="[ProductName]" NoMinimize="yes" >
<!-- Virtual Dir prompt -->
<Control Id="Office32" Type="RadioButtonGroup" Property="officeVersion" Height="100" Width="200" X="50" Y="50">
<RadioButtonGroup Property="officeVersion">
<RadioButton Value="32" Text="Microsot Office Version 32bit" Height="17" Width="200" X="0" Y="0"/>
<RadioButton Value="64" Text="Microsot Office Version 64bit" Height="17" Width="200" X="0" Y="20"/>
</RadioButtonGroup>
</Control>
<!-- Back button -->
<Control Id="Back" Type="PushButton" X="180" Y="243"
Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Install" Type="PushButton" X="236" Y="243"
Width="56" Height="17" Default="yes" Text="&Install" ElevationShield="yes">
<Publish Event="EndDialog" Value="Return" Order="1">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243"
Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0"
Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23"
Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please select Microsoft Office Version</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234"
Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6"
Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Microsoft Office select version</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>
And another problem when the system is 64 bit I can not copy the file to C:\Windows\System32. The system automatically overrides the folder in C: \ WINDOWS \ SysWOW64 \
Transformed into public property and it was considered
Use attribute “Secure” to denote that the Property can be passed to the server side when doing a managed installation with elevated privileges.
<Property Id="OFFICEVERSION" Secure="yes" Value="32"/>

How to pass the Parameters to custom action method in wix

I am new to create MSI installer using wix tool,here i have a query please help me how to resolve this .
My query is : I have create a custom UI , in this i have a combo box control and i have bind the combo box values as dynamically using custom Action method it's working fine . Now, i want pass the parameters(combo box selected value) to custom action method,i don't know how to pass parameters .I goggled but i did not get answer please help me.
Here is my code
<Binary Id="CustomActions" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll" />
<CustomAction Id='Action1' BinaryKey='CustomActions' DllEntry='FillServerInstances' Execute='immediate' Return='check' />
<UI>
<Dialog Id="CustomWelcomeEulaDlg" Width="600" Height="450" Title="!(loc.WelcomeEulaDlg_Title)">
<Control Id="Bitmap" Type="Bitmap" X="0" Y="44" Width="600" Height="380" TabSkip="no" Text="MainImage" />
<Control Id="Next" Type="PushButton" X="290" Y="430" Width="60" Height="17" Default="yes" Text="Next">
<Publish Event="DoAction" Value="Action1">1</Publish>
<Publish Event="NewDialog" Value="LicenseAgreementDlgs"><![CDATA[1]]></Publish>
<Publish Event="ReinstallMode" Value="ecmus"><![CDATA[Installed = 1]]></Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="350" Y="430" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="Title" Type="Text" X="15" Y="6" Width="300" Height="15" Transparent="yes" NoPrefix="yes">
<Text>[DlgTitleFont]Welcome to the [ProductName] [Wizard]</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="600" Height="0" />
</Dialog>
Latest Code
<Product Id="22d32870-651b-4eee-a622-27b2daaade8c" Name="Small Business" Language="1033" Version="1.0.0.0" Manufacturer="Small Business Manufacturing" UpgradeCode="01b2dc2f-61f3-4ff0-a0ba-94dd4cb0829d">
<Package InstallerVersion="200" Compressed="yes" />
<Property Id="MSIFASTINSTALL" Value="3" />
<Binary Id="BIN_CustomAction" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll"/>
<Binary Id="myAction" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll"/>
<UIRef Id="WixUI_CustomMinimal" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Property Id="FILEPATH" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Small Business Manufacturing">
<Component Id="Component" Guid="af10d5b4-5d25-474f-8360-13b6c0cd7a53">
<File Id="Component" Source="D:\WIX Projects\Small Business Manufacturing\Small Business Manufacturing\bin\Debug\Myproject.exe" Compressed="yes" KeyPath="yes" Checksum="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="Installation Target" Level="1">
<ComponentRef Id="Component" />
</Feature>
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallFinalize"></Custom>
</InstallExecuteSequence>
<CustomAction Id="SetCustomActionDataValue" Return="check" Property="myActionId" Value="AnotherValue=[Sqlinstaces]" />
<UI>
<ProgressText Action="RunEXE">Configuring Foo... (this may take a few minutes).</ProgressText>
</UI>
</Product>
As far as I am aware you can't pass parameters to custom actions. You can set a property in Wix and use WcaGetProperty to access that.
I use a listbox which is similar like so:
<!--This will be populated via the custom action-->
<Control Id="ListBoxID" Type="ListBox" Property="COMPORT" Width="80" Height="40" X="80" Y="165" Indirect="no">
<ListBox Property="COMPORT">
</ListBox>
</Control>
And in my C++ Custom Action:
hr = WcaGetFormattedProperty(L"COMPORT",&szComport);
ExitOnFailure(hr, "failed to get Com Port");
EDIT:
Ok so I am assuming your ComboBox is something like this:
<Control Id="DummyComboBox" Hidden="yes" Type="ComboBox" Sorted="yes" ComboList="yes" Property="DUMMYPROPERTY" X="65" Y="60" Width="150" Height="18">
<ComboBox Property="DUMMYPROPERTY">
</ComboBox>
Make sure your property is is defined like so(ensure capital letters):
<Property Id="DUMMYPROPERTY" Secure="yes"></Property>
You do not need a custom action to send the value of the property. All you have to do is use:
LPWSTR dummyText = NULL;
hr = WcaGetProperty(L"DUMMYPROPERTY", &dummyText);
ExitOnFailure(hr, "failed to get Dummy Text");
That is for a C++ Custom Action not sure what you are using but a quick google search would tell you the relevant code to use.

WiX Error LGHT0130 In InstallScopeDlg when modifying Wix_Advanced UI

I am using WiX 3.6.
I am using the WIX_Advanced user interface and I want to replace the InstallScopeDlg with my own version (called InstallScopeDlgDsktp) which includes a checkbox for adding a Desktop shortcut.
When I do this, I take all the references to the old InstallScopeDlg in the WixUI_Advanced.wxs file, and override them in my main file to instead reference my custom InstallScopeDlgDsktp module.
However, when I try compiling, I get an error which seems to indicate there is a clash with a RadioButton table which means both my InstallScopeDlgDsktp and the original InstallScopeDlg must be adding a RadioButton based on the same property (WixAppFolder).
light Cryptobot.wixobj InstallScopeDlgDsktp.wixobj -ext WixUIExtension -out Cryptobot.msi
Microsoft (R) Windows Installer Xml Linker version 3.6.2221.0
<snip>wixlib\InstallScopeDlg.wxs(24): error LGHT0130 :
The primary key 'WixAppFolder/1' is duplicated in table 'RadioButton'. Please remove one of the entries or rename a part of the primary key to avoid the collision.
I can't seem to get around this. My question is, why is it even linking in the original InstallScopeDlg module when I am not even referencing it any more? How do I stop the original InstallScopeDlg from adding the RadioButton?
Code provided for reference:
Main WXS file (UI stuff is at the bottom - can see I replaced all instances of InstallScopeDlg with InstallScopeDlgDsktp):
<?xml version="1.0" encoding="windows-1252"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Defines -->
<?define ProductName="Cryptobot" ?>
<?define ProductVersion="1.1.1" ?>
<Product Name="$(var.ProductName) $(var.ProductVersion)" Id="*"
UpgradeCode="MY-UPGRADE-GUID"
Language="1033" Codepage="1252" Version="$(var.ProductVersion)" Manufacturer="Crafted From Code">
<!-- The Package GUID must be changed EVERY timeyou build a new .msi. The asterisk makes this happen automatically. -->
<Package Id="*" Keywords="Installer"
Description="$(var.ProductName) $(var.ProductVersion) Setup"
Manufacturer="Crafted From Code"
InstallerVersion="200" Languages="1033" Compressed="yes" />
<Media Id="1" Cabinet="$(var.ProductName).cab" EmbedCab="yes" />
<!-- Components to install -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CraftedFromCode" Name="Crafted From Code">
<Directory Id="APPLICATIONFOLDER" Name="$(var.ProductName)">
<Component Id="MainExecutable" Guid="MY-GUID">
<File Id="CryptobotEXE" Name="Cryptobot.exe" Source="..\Cryptobot\bin\Release\Cryptobot.exe" KeyPath="yes">
<Shortcut Id="CryptobotProgramMenuShortcut" Directory="ProgramMenuDir"
Name="$(var.ProductName)" Icon="Cryptobot.ico" IconIndex="0" Advertise="yes" />
<Shortcut Id="CryptobotDesktopShortcut" Directory="DesktopFolder"
Name="$(var.ProductName)" Icon="Cryptobot.ico" IconIndex="0" Advertise="yes" />
</File>
<RemoveFolder Id="APPLICATIONFOLDER" On="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
<!-- Start Menu Shortcut(s) -->
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="$(var.ProductName)">
<Component Id="ProgramMenuShortcut" Guid="MY-GUID" >
<RegistryValue Root="HKCU" Key="Software\Crafted From Code\Cryptobot" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
</Component>
</Directory>
</Directory>
<!-- Desktop Shortcut -->
<Directory Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="MY-GUID">
<Condition>INSTALLDESKTOPSHORTCUT</Condition>
<RegistryValue Root="HKCU" Key="Software\Crafted From Code\Cryptobot" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Directory>
</Directory> <!-- End of TARGETDIR root directory -->
<Icon Id="Cryptobot.ico" SourceFile="Cryptobot.ico" />
<Feature Id="Complete" Level="1" Title="$(var.ProductName)"
Description="The complete package." Display="expand"
ConfigurableDirectory="APPLICATIONFOLDER">
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="ProgramMenuShortcut" />
<ComponentRef Id="DesktopShortcut" />
</Feature>
<!-- Upgrade rules: If a newer version is found, don't allow installation of an older version (downgrading).
Otherwise, if an older version is already installed, remove it before installing the current version -->
<Upgrade Id="MY-UPGRADE-GUID">
<UpgradeVersion OnlyDetect="yes" Property="NEWERPRODUCTFOUND" Minimum="$(var.ProductVersion)" IncludeMinimum="no" />
<!-- Setting IncludeMaximum to yes generates a linker warning, but it means that we can install over the
same version without necessarily having to change the version number. -->
<UpgradeVersion OnlyDetect="no" Property="PREVIOUSVERSIONINSTALLED" Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="yes" />
</Upgrade>
<CustomAction Id='PreventDowngrading' Error='A newer version of $(var.ProductName) is already installed.' />
<InstallExecuteSequence>
<Custom Action='PreventDowngrading' After='FindRelatedProducts'>NEWERPRODUCTFOUND</Custom>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action='PreventDowngrading' After='FindRelatedProducts'>NEWERPRODUCTFOUND</Custom>
</InstallUISequence>
<!-- User Interface: Use the Advanced WiX interface, which will allow 1-click installation or
per user/per machine installation & install directory to be specified -->
<UIRef Id="WixUI_Advanced" />
<UIRef Id="WixUI_ErrorProgressText" />
<Property Id="ApplicationFolderName" Value="Crafted From Code\Cryptobot" />
<Property Id="WixAppFolder" Value="WixPerUserFolder" /> <!-- Defaults to install for all users -->
<Property Id="INSTALLDESKTOPSHORTCUT" Value="1" /> <!-- Support for a desktop shortcut -->
<!-- Add a checkbox to launch the application when the installer exits -->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.ProductName) when setup exits." />
<!-- Have it ticked by default -->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<CustomAction Id="StartAppOnExit" FileKey="CryptobotEXE" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />
<UI Id="WixUI_AdvancedCrypto">
<UIRef Id="WixUI_Advanced" />
<DialogRef Id="InstallScopeDlgDsktp" />
<Publish Dialog="AdvancedWelcomeEulaDlg" Control="Advanced" Event="NewDialog" Value="InstallScopeDlgDsktp" Order="1">!(wix.WixUISupportPerMachine) AND !(wix.WixUISupportPerUser)</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Back" Event="NewDialog" Value="AdvancedWelcomeEulaDlg">1</Publish>
<!-- override default WixAppFolder of WixPerMachineFolder as standard user won't be shown the radio group to set WixAppFolder -->
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Property="WixAppFolder" Value="WixPerUserFolder" Order="1">!(wix.WixUISupportPerUser) AND NOT Privileged</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Property="ALLUSERS" Value="{}" Order="2">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Property="ALLUSERS" Value="1" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Property="APPLICATIONFOLDER" Value="[WixPerUserFolder]" Order="4">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Property="APPLICATIONFOLDER" Value="[WixPerMachineFolder]" Order="5">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Event="NewDialog" Value="FeaturesDlg" Order="6">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlgDsktp" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="7">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="FeaturesDlg" Control="Back" Event="NewDialog" Value="InstallScopeDlgDsktp">NOT Installed AND WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="InstallScopeDlgDsktp">!(wix.WixUISupportPerUser)</Publish>
<!-- Add the check box for launching the app on completion -->
<Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="StartAppOnExit">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 AND NOT Installed</Publish>
</UI>
</Product>
</Wix>
And the InstallScopeDlgDsktp file is just a copy of InstallScopeDlg with a checkbox added and the name changed:
<snip>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="InstallScopeDlgDsktp" Width="370" Height="270" Title="!(loc.InstallScopeDlg_Title)" KeepModeless="yes">
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallScopeDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="20" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgDescription)" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgTitle)" />
<Control Id="BothScopes" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="120" Property="WixAppFolder" Hidden="yes">
<RadioButtonGroup Property="WixAppFolder">
<RadioButton Value="WixPerUserFolder" X="0" Y="0" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerUser)" />
<RadioButton Value="WixPerMachineFolder" X="0" Y="60" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerMachine)" />
</RadioButtonGroup>
<Condition Action="show">Privileged AND (!(wix.WixUISupportPerUser) AND !(wix.WixUISupportPerMachine))</Condition>
</Control>
<Control Id="PerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerUserDescription)">
<Condition Action="show">!(wix.WixUISupportPerUser)</Condition>
</Control>
<Control Id="NoPerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgNoPerUserDescription)">
<Condition Action="show">NOT !(wix.WixUISupportPerUser)</Condition>
</Control>
<Control Id="PerMachineDescription" Type="Text" X="33" Y="131" Width="300" Height="36" Hidden="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerMachineDescription)">
<Condition Action="show">Privileged</Condition>
</Control>
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="20" Y="160" Width="290" Height="17" Property="INSTALLDESKTOPSHORTCUT" CheckBoxValue="1" Text="Create a shortcut on the desktop." />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>
You are still referencing the original WixUI_Advanced UI.
<UI Id="WixUI_AdvancedCrypto">
<UIRef Id="WixUI_Advanced" />
<DialogRef Id="InstallScopeDlgDsktp" />
This pulls in the InstallScopeDlg and will be causing your conflict. Take a copy of the WixUI_Advanced wxs from the wix sources and include in your project renaming it so that it doesn't conflict and then modify it to use your new InstallScopeDlgDsktop.

Web application install with initial IIS settings; using WiX, need upgrade files, NOT changing IIS settings

I have a WiX install project that includes IIS setings for virtual directory and application settings with an application pool. After initial install, the customer will change the application pool identity from default network service set in wxs.
How can I build an update installer that can update web files, but not change the IIS settings, application pool identity back to network service?
ComponentGroupRef Id="WebPublishCmp" is the initial heat output of the web files to publish.
I have tried to build a minor upgrade using Torch and Pyro, but I am having issues with Torch diff not detecting changes (this is another issue for another Stack Overflow question).
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<?include Config.wxi ?>
<Product
Id="E3105F82-0460-4C3C-8F6C-778405E81F61"
Name="Website"
Language="1033"
Version="1.0.0.1"
Manufacturer="Website"
UpgradeCode="E3105F82-0460-4C3C-8F6C-778405E81F61">
<Package
InstallerVersion="200" Compressed="yes" />
<Media
Id="1"
Cabinet="media1.cab"
EmbedCab="yes" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
<UIRef Id="CustomWixUI_InstallDir"/>
<FeatureRef Id="InitialFeature"/>
</Product>
<Fragment>
<Feature Id="InitialFeature" Title="Initial (Full)" Level="1">
<ComponentGroupRef Id="WebPublishCmp"/>
<ComponentRef Id="IIS.Component"/>
</Feature>
<Feature Id="WebFilesFeature" Title="Website (Files)" Level="1">
<ComponentGroupRef Id="WebPublishCmp"/>
</Feature>
</Fragment>
<Fragment>
<Component Id="IIS.Component" Guid="6FAD9EC7-D2B0-4471-A657-C8AF5F6F707F" KeyPath="yes" Directory="INSTALLLOCATION">
<iis:WebSite Id="DefaultWebSite" Description="$(var.WebSiteName)" Directory="INSTALLLOCATION" >
<iis:WebAddress Id="AllUnassigned" Port="80"/>
</iis:WebSite>
<iis:WebAppPool Id="WebsiteAppPool" Name="App" Identity="networkService" />
<iis:WebVirtualDir Id="My.VirtualDir" Alias="App" Directory="INSTALLLOCATION" WebSite="DefaultWebSite">
<iis:WebApplication Id="Application" Name="App" WebAppPool="WebsiteAppPool"/>
</iis:WebVirtualDir>
</Component>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Website">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
I am using:
WiX 3.5, 3.6
Visual Studio 2010
I apologize ahead of time for the long answer:
I recommend keeping your Website and Content in two separate features and then giving them the option of supplying any variables needed for installation via UI or command line parameters. If you use the "Remember Property" pattern, then you can recall the variables used when changing or upgrading an installation (read all the way through the last comments, there is a slightly simpler way of doing it).
This allows the person installing the product to set up everything with the given variables or set up the IIS website on their own and install only website content.
This also jives well with MajorUpgrades. I don't currently see upgrade information in code you provided, so you should look into MajorUpgrades vs patches (major upgrades are much easier)
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of of this product is already installed. Setup will now exit."/>
Remember, variables accessed by $(var.name) are used at MSI compile time, whereas public variables accessed via brackets [MY_VARIABLE] are used at install time. Public variables can be exposed through the MSI UI, or provided to msiexec via command line (I use this for silent installs and/or specifying a log file)
Here is a summary of the examples included below:
Configuration.wxi - This file implements the "remembered" properties
Product.wxs - Mostly like yours, but also includes MajorUpgrades, separate features for the website and content, and an inclusion of the UiFlow
IISConfiguration.wxs - A fragment containing the IIS Website, AppPool, and AppPool User using variables supplied at install time
UIFlow.wxs - Defining the flow of the UI to use, it's using the WixUI FeatureTree plugin, you may require something else for your UI
UIDialogs.wxs - This is where the variables used in installation are exposed to the UI
Configuration.wxi:
<?xml version="1.0" encoding="utf-8" ?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<!-- The RegistrySearch elements will populate these properties with values from the registry IF they exist there, otherwise the default values will be used -->
<Property Id="REG_WEBSITE_NAME" Value="WebsiteName" >
<RegistrySearch Id="WEB_WEBSITE_NAME_Remembered" Root="HKLM" Key="SOFTWARE\PRODUCT_NAME" Name="Website_Name" Type="raw" />
</Property>
<Property Id="REG_WEB_APP_POOL_NAME" Value="PoolName" >
<RegistrySearch Id="WEB_APP_POOL_NAME_Remembered" Root="HKLM" Key="SOFTWARE\PRODUCT_NAME" Name="WebApp_PoolName" Type="raw" />
</Property>
<Property Id="REG_WEB_APP_POOL_IDENTITY_DOMAIN">
<RegistrySearch Id="WEB_APP_POOL_IDENTITY_DOMAIN_Remembered" Root="HKLM" Key="SOFTWARE\PRODUCT_NAME" Name="WebApp_PoolIdentityDomain" Type="raw" />
</Property>
<Property Id="REG_WEB_APP_POOL_IDENTITY_USERNAME" Value="NetworkService" >
<RegistrySearch Id="WEB_APP_POOL_IDENTITY_USERNAME_Remembered" Root="HKLM" Key="SOFTWARE\PRODUCT_NAME" Name="WebApp_PoolIdentityUsername" Type="raw" />
</Property>
<!-- Notice that the password is NOT stored in the registry and is hidden so it's not shown in logs -->
<Property Id="WEB_APP_POOL_IDENTITY_PWD" Hidden="yes" />
<!-- This is the compnent that actually writes the values to the registry on install -->
<Component Id="C_RegistryEntries" Directory="INSTALLLOCATION">
<RegistryValue Root="HKLM" Key="SOFTWARE\ProviderWebsites" Name="Website_Name" Type="string" Value="[WEBSITE_NAME]"/>
<RegistryValue Root="HKLM" Key="SOFTWARE\ProviderWebsites" Name="WebApp_PoolName" Type="string" Value="[WEB_APP_POOL_NAME]"/>
<RegistryValue Root="HKLM" Key="SOFTWARE\ProviderWebsites" Name="WebApp_PoolIdentityDomain" Type="string" Value="[WEB_APP_POOL_IDENTITY_DOMAIN]"/>
<RegistryValue Root="HKLM" Key="SOFTWARE\ProviderWebsites" Name="WebApp_PoolIdentityUsername" Type="string" Value="[WEB_APP_POOL_IDENTITY_USERNAME]"/>
</Component>
<!-- These CustomActions set the property that are used for the install from the registry values (These actions are only run under the conditions in the sequences below) -->
<CustomAction Id='SetWebAppName' Property='WEBSITE_NAME' Value='[REG_WEBSITE_NAME]'/>
<CustomAction Id='SetWebAppPoolName' Property='WEB_APP_POOL_NAME' Value='[REG_WEB_APP_POOL_NAME]'/>
<CustomAction Id='SetWebAppPoolIdentityDomain' Property='WEB_APP_POOL_IDENTITY_DOMAIN' Value='[REG_WEB_APP_POOL_IDENTITY_DOMAIN]'/>
<CustomAction Id='SetWebAppPoolIdentityUsername' Property='WEB_APP_POOL_IDENTITY_USERNAME' Value='[REG_WEB_APP_POOL_IDENTITY_USERNAME]'/>
<!-- The CustomActions above that set the variables used in the installation are only run if they were not supplied by the command line -->
<InstallUISequence>
<Custom Action='SetWebAppName' After='AppSearch'>REG_WEBSITE_NAME AND (NOT WEBSITE_NAME)</Custom>
<Custom Action='SetWebAppPoolName' After='AppSearch'>REG_WEB_APP_POOL_NAME AND (NOT WEB_APP_POOL_NAME)</Custom>
<Custom Action='SetWebAppPoolIdentityDomain' After='AppSearch'>REG_WEB_APP_POOL_IDENTITY_DOMAIN AND (NOT WEB_APP_POOL_IDENTITY_DOMAIN)</Custom>
<Custom Action='SetWebAppPoolIdentityUsername' After='AppSearch'>REG_WEB_APP_POOL_IDENTITY_USERNAME AND (NOT WEB_APP_POOL_IDENTITY_USERNAME)</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<!-- After='RemoveExistingProducts' is used under this sequence because of the use of MajorUpgrades -->
<Custom Action='SetWebAppName' After='RemoveExistingProducts'>REG_WEBSITE_NAME AND (NOT WEBSITE_NAME)</Custom>
<Custom Action='SetWebAppPoolName' After='RemoveExistingProducts'>REG_WEB_APP_POOL_NAME AND (NOT WEB_APP_POOL_NAME)</Custom>
<Custom Action='SetWebAppPoolIdentityDomain' After='RemoveExistingProducts'>REG_WEB_APP_POOL_IDENTITY_DOMAIN AND (NOT WEB_APP_POOL_IDENTITY_DOMAIN)</Custom>
<Custom Action='SetWebAppPoolIdentityUsername' After='RemoveExistingProducts'>REG_WEB_APP_POOL_IDENTITY_USERNAME AND (NOT WEB_APP_POOL_IDENTITY_USERNAME)</Custom>
</InstallExecuteSequence>
</Include>
Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<!--NEVER EVER EVER EVER CHANGE THE UPGRADE CODE!!!!!!!!!!!!!!! -->
<?define UpgradeCode="PUT-GUID-HERE" ?>
<Product Id="*" Name="ProductName" Language="1033" Version="X.X.X.X" Manufacturer="XYZ" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200" Compressed="yes" />
<!-- This includes our properties that implement the "Remember Property" pattern -->
<?include Configuration.wxi ?>
<Media Id="1" Cabinet="media.cab" EmbedCab="yes" />
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of this product is already installed. Setup will now exit."/>
<!-- Creating default directory structure (INSTALLLOCATION be override by user, but it starts in Program Files) -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id="INSTALLLOCATION" Name="TheDefaultInstallFolderName">
</Directory>
</Directory>
</Directory>
<Feature Id="F_Content" Title="Content" Level="1" Description="The website content" ConfigurableDirectory="INSTALLLOCATION">
<ComponentRef Id="C_RegistryEntries"/>
<!-- The C_WebAppContent can either be generated by the WiX tool "heat", or a hand-crafted set of content, this component is not included in this example -->
<ComponentGroupRef Id="C_WebAppContent" />
</Feature>
<Feature Id="F_IISWebsite" Title="IIS Website" Description="The IIS website and application pool" Level="1">
<ComponentRef Id="C_IISWebsite" />
</Feature>
<InstallExecuteSequence>
</InstallExecuteSequence>
<!-- Specify UI -->
<UIRef Id="UIFlow" />
</Product>
</Wix>
IISConfiguration.wxs:
<?xml version="1.0" encoding="utf-8" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<DirectoryRef Id="INSTALLLOCATION">
<Component Id="C_IISWebsite" Guid="{PUT-GUID-HERE}" KeyPath="yes">
<!-- This does not create a user, it's just an object that's referenced by the WebAppPool component -->
<util:User Id="WebAppPoolUser" CreateUser="no" Name="[WEB_APP_POOL_IDENTITY_USERNAME]"
Password="[WEB_APP_POOL_IDENTITY_PWD]" Domain="[WEB_APP_POOL_IDENTITY_DOMAIN]"/>
<!-- The "Identity" attritbute below needs to be set to "other" to use the util:User defined above -->
<iis:WebAppPool Id="WebAppPool" Name="[WEB_APP_POOL_NAME]" Identity="other" User="WebAppPoolUser"/>
<iis:WebSite Id="DefaultWebSite" Description="[WEBSITE_NAME]" Directory="INSTALLLOCATION" >
<iis:WebAddress Id="AllUnassigned" Port="80"/>
</iis:WebSite>
<iis:WebVirtualDir Id="My.VirtualDir" Alias="App" Directory="INSTALLLOCATION" WebSite="DefaultWebSite">
<iis:WebApplication Id="Application" Name="App" WebAppPool="WebAppPool"/>
</iis:WebVirtualDir>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
UIFlow.wxs:
<?xml version="1.0" encoding="utf-8" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI Id="UIFlow">
<!-- This uses the WixUI plugin -->
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<!-- Injection of custom UI. -->
<DialogRef Id="IisSetupDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="IisSetupDlg" Order="3">LicenseAccepted = "1"</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="PoolSettingsDlg">1</Publish>
</UI>
</Fragment>
</Wix>
UIDialogs.wxs:
<?xml version="1.0" encoding="utf-8" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="IisSetupDlg" Width="370" Height="270" Title="IIS Settings - [ProductName]" NoMinimize="yes">
<!-- Web App details prompt -->
<Control Id="WebsiteNameLabel" Type="Text" X="45" Y="53" Width="100" Height="15" TabSkip="no" Text="&Website Name:" />
<Control Id="WebsiteNameEdit" Type="Edit" X="45" Y="65" Width="220" Height="18" Property="WEBSITE_NAME" Text="{80}" />
<!-- Back button -->
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next">
<Publish Event="NewDialog" Value="PoolSettingsDlg">
<!--if settings are correct, allow next dialog-->
<![CDATA[WEBSITE_NAME <> ""]]>
</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter IIS Configuration</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}IIS Settings</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
<Dialog Id="PoolSettingsDlg" Width="370" Height="300" Title="Application Pool Settings - [ProductName]" NoMinimize="yes">
<!-- name of the application pool -->
<Control Id="PoolNameLabel" Type="Text" X="45" Y="53" Width="100" Height="15" TabSkip="no" Text="&Pool name:" />
<Control Id="PoolNameEdit" Type="Edit" X="45" Y="65" Width="220" Height="18" Property="WEB_APP_POOL_NAME" Text="{80}" />
<!-- domain -->
<Control Id="DomainPoolLabel" Type="Text" X="45" Y="85" Width="100" Height="15" TabSkip="no" Text="&Domain for AppPool:" />
<Control Id="DomainPoolEdit" Type="Edit" X="45" Y="97" Width="220" Height="18" Property="WEB_APP_POOL_IDENTITY_DOMAIN" Text="{80}" />
<!-- Login -->
<Control Id="LoginPoolLabel" Type="Text" X="45" Y="117" Width="100" Height="15" TabSkip="no" Text="&Login for AppPool:" />
<Control Id="LoginPoolEdit" Type="Edit" X="45" Y="129" Width="220" Height="18" Property="WEB_APP_POOL_IDENTITY_USERNAME" Text="{80}" />
<!-- Password -->
<Control Id="PasswordPoolLabel" Type="Text" X="45" Y="149" Width="100" Height="15" TabSkip="no" Text="&Password for AppPool:" />
<Control Id="PasswordPoolEdit" Type="Edit" X="45" Y="161" Width="220" Height="18" Property="WEB_APP_POOL_IDENTITY_PWD" Text="{80}" Password="yes" />
<!-- Back button -->
<Control Id="Back" Type="PushButton" X="180" Y="264" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="IisSetupDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="264" Width="56" Height="17" Default="yes" Text="&Next">
<Publish Event="NewDialog" Value="CustomizeDlg">
<!--if settings are correct, allow next dialog-->
<![CDATA[WEB_APP_POOL_NAME <> ""
or WEB_APP_POOL_IDENTITY_DOMAIN <> ""
or WEB_APP_POOL_IDENTITY_USERNAME <> ""
or WEB_APP_POOL_IDENTITY_PWD <> ""]]>
</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="264" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter AppPool Configuration for IIS</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="255" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Application Pool Settings</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>