I can't seem to get a custom action working. I might be doing this wrong. Here's what I'm trying to do:
I'd like to run a custom action in my application install (Visual Studio Installer project) that runs an executable. The executable simply does some system.io filecopy tasks, and I've confirmed that the executable when ran by itself works perfectly.
Any thoughts?
Targeted Systems: Windows XP, Vista Visual Studio Version: 2008 Sp1 Language: VB.NET Targeted Framework: 2.0
Excellent. I think I'm getting closer thanks to the code you posted. I converted it to VB and i'm getting this error: Cannot Find myexename.savedstate. I assume I'm supposed to pass something to the subs you posted but I don't know what. (by the way this is a console application) I added a reference to the System.Configuration.Install.dll and here is my code:
Imports System.ComponentModel Imports System.Configuration.Install _ Public Class ApplicationInstaller Inherits Installer Public Overloads Overrides Sub Commit(ByVal savedState As IDictionary) ' Do some work on commit The_Sub_I_Want_To_Run() End Sub Public Overloads Overrides Sub Install(ByVal stateSaver As IDictionary) ' Do some work on install End Sub Public Overloads Overrides Sub Uninstall(ByVal savedState As IDictionary) ' Do some work on uninstall End Sub End Class
I did not call that. I've never used the Installer class before. I might be doing something very rookie here. Per your instructions, I've added the code that I have pasted below in the exe I want to run during my install. I added the exe to my application folder, then added it to the Commit custom action. Now here is the code I now have in the source of my exe that I'm trying to run:
_ Public Class ApplicationInstaller Inherits Installer Public Overloads Overrides Sub Commit(ByVal savedState As IDictionary) ' Do some work on commit The_Sub_I_Have_my_codein() MyBase.Commit(savedState) End Sub Public Overloads Overrides Sub Install(ByVal stateSaver As IDictionary) ' Do some work on install End Sub Public Overloads Overrides Sub Uninstall(ByVal savedState As IDictionary) ' Do some work on uninstall End Sub End Class
Hmmm... In the exe's Project Properties I clicked "Sign the assembly" and the error has gone away. However, looks like the exe doesn't run the code I want it to.
The exe or library you are adding to the Commit step should contain a class deriving from Installer and marked with the RunInstaller attribute as follows:
[RunInstaller(true)]
public class ApplicationInstaller : Installer
{
public override void Commit(IDictionary savedState) {
// Do some work on commit
}
public override void Install(IDictionary stateSaver) {
// Do some work on install
}
public override void Uninstall(IDictionary savedState) {
// Do some work on uninstall
}
}
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With