Reafidy
Reafidy

Reputation: 8441

Convert a VS Setup Project Custom Action to InstallShield Project Custom Action

I have a standard visual studio setup project that I am converting to an InstallShield LE project.

I have the following custom action under CustomActions-Install-PrimaryOutputFromMyProject(Active) - CustomActionData - /sectionName="userSettings/SSE.My.MySettings" /provName="DPAPIProtection"

How do I recreate this custom action in InstallShield?

Here is the code in my installer class all it does is protect some of the sections of the app.config file:

Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.Configuration

'// This file encrypts the app.config file
Public Class CustomInstaller
    Inherits Installer
    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        'Add initialization code after the call to InitializeComponent

    End Sub
    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)

        'get Configuration section 
        'name from custom action parameter
        Dim sectionName As String = Me.Context.Parameters("sectionName")

        'get Protected Configuration Provider 
        'name from custom action parameter
        Dim provName As String = Me.Context.Parameters("provName")

        ' get the exe path from the default context parameters
        Dim exeFilePath As String = Me.Context.Parameters("assemblypath")

        'encrypt the configuration section
        ProtectSection(sectionName, provName, exeFilePath)
    End Sub
    Private Sub ProtectSection(ByVal sectionName As String, ByVal provName As String, ByVal exeFilePath As String)
        Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(exeFilePath)
        Dim section As ConfigurationSection = config.GetSection(sectionName)

        If Not section.SectionInformation.IsProtected Then
            'Protecting the specified section with the specified provider
            section.SectionInformation.ProtectSection(provName)
        End If
        section.SectionInformation.ForceSave = True
        config.Save(ConfigurationSaveMode.Modified)
    End Sub

End Class

Upvotes: 2

Views: 2216

Answers (2)

Christopher Painter
Christopher Painter

Reputation: 55581

You should read my augmenting series:

Augmenting InstallShield using Windows Installer XML - Certificates

Augmenting InstallShield using Windows Installer XML - Windows Services

Basically I would do it this way:

1) Refactor the code in your InstallerClass ( InstallUtil ) custom action into a WiX DTF custom action. This step is technically optional but if you know all the horrible things associated with InstallUtil you'd do it to.

2) Author a WiX merge module to consume the DLL as a custom action and sequence it in the ModuleExecuteSequence table.

3) Add the merge module to your InstallShield LE project.

Note: InstallShield 2010LE is basically stripped-down-featureset-ware. You can use it for upgrade pricing of $1500 to InstallShield Professional edition. If you can justify this, I would do it. The reality is LE has some capabilities and I can think of some creative ways of augmenting it but it's far easier to do in normal InstallShield.

Upvotes: 3

Cosmin
Cosmin

Reputation: 21416

InstallShield doesn't really support project output custom actions. This is because Windows Installer uses EXE and DLL custom actions as specific files, not as a dynamic outputs.

Also, InstallShield LE doesn't support DLL custom actions. So you can use only an EXE, VBScript or JScript.

Since you used CustomActionData, I'm guessing your project output is a DLL. You cannot create a DLL custom action in InstallShield LE.

Upvotes: 1

Related Questions