Reputation: 1705
Looking for clarity on how to begin writing wix extensions. Was reading this page, which allows one to begin to create a wix extension for adding custom actions to an installer.
Next, wanting to know how to begin coding up the action itself, I dropped in the old installscript code for one method and began to correct it. Choking on MsiGetProperty, I wanted to figure out what I needed to import via "using" to make it available. I then came across this page which appears to have other attributes employed which are not referenced on the wix skeleton page. I then thought, "I wonder if there was a project type for wix extensions made when I instlled it?" and yes, there was! Code fragment looks like that from the second link, neither of which reflect what is on the wix page...
So, what do I do? I have several custom actions to port from installshield and just need a solid example of how to construct the project and methods and hook it into my wix xml file. Thanks!
Upvotes: 0
Views: 132
Reputation: 212
Ill give you an example of how i do it :
First Create your Custom Action:
[CustomAction]
public static ActionResult CreateIisConfigs(Session session)
{
try
{
LoadXmlFile(session);
var iisSettings = new IisSettings
{
PathName = session["PATHNAME"],
UserPath = session["USERPATH"],
Website = session["WEBSITE"],
SqlDataSource = session["BLOBSQLDATASOURCE"],
AppPool = session["BLOBAPPLICATIONPOOL"],
ApplicationName = session["BLOBAPPLICATION"],
ApplicationPath = @"Sites\Blabla.Application.WebAPI.Blobs",
EnvirName = session["BLOBENVIRONMENTNAME"],
EnvirPath = session["ENVIRONMENTPATH"],
IdentityDomainType = session["BLOBIDENTITYDOMAIN"],
SitePhysPath = session["SITEPHYSPATH"],
SqlPass = session["BLOBSQLPASSWORD"],
SqlUser = session["BLOBSQLUSER"],
SslCertPath = session["SSLCERTPATH"],
SslCertPass = session["SSLCERTPASS"],
UserAppl = session["BLOBUSERAPPLICATION"],
};
IisConfigs.ApplyNewConfigs(iisSettings);
}
catch (Exception e)
{
session.Log("----------------------------------------IIS ERROR ---------------------------------------");
session.Log(e.ToString());
return ActionResult.Failure;
}
return ActionResult.Success;
}
Then in your wxs initialise the properties etc.. :
<Property Id="PATHNAME" Hidden="yes"/>
<Property Id ="WEBSITE" Hidden="yes"/>
<Property Id="SITEPHYSPATH" Hidden="yes"/>
<Property Id="USERPATH" Hidden="yes"/>
Declare your Binary which references to the dll or the custom action :
<Binary Id="CustomActionsId" SourceFile="..\Blob.CustomActions\bin\Debug\Blob.CustomActions.CA.dll"/>
Declare your custom action :
<CustomAction Id="CreateIisConfigs" BinaryKey="CustomActionsId" Return="check" Execute="immediate" DllEntry="CreateIisConfigs" />
Last decide how the custom action will execute :
<InstallExecuteSequence>
<Custom Action="CreateIisConfigs" Before="InstallInitialize">NOT Install</Custom>
</InstallExecuteSequence>
Upvotes: 1