I am writing an installer for my web app and I struggle with the uninstaller part. Despite the fact that I created a custom action on Uninstall in my Application Setup Project, the InstallerClass is set to true, the method:
public override void Uninstall(IDictionary savedState)
{
//MessageBox.Show("Attach debugger!", "Viper.Setup");
Cleanup();
base.Uninstall(savedState);
}
on the installer class doesn't seem to be called. Any ideas what could be the reason?
EDIT: I also noticed that it not only doesn't run the Installer, but also doesn't delete my main dll file. To make it worse, when I install a new version after uninstalling the previous one, this dll is still the old one (even though installation and uninstallation were successful)
Did you include the output of your installer code in the Code Actions tab of the installer?
If that's not it...
I ran into a similar problem in the past and found I needed all 4 methods defined or the uninstall would not run. Add your code to the template below:
[RunInstaller(true)]
public class MyInstaller: Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
}
Hope this helps!
I don't Know actually why your override uninstall not working . But whenever i face this issue
i make a log of the uninstall process . And according to that you can easily check where the problem resides ! Here is the method to make a log by installer class.
private string logFilePath = "C:\\SetupLog.txt";
public void Log(string str)
{
StreamWriter Tex;
try
{
Tex = File.AppendText(this.logFilePath);
Tex.WriteLine(DateTime.Now.ToString() + " " + str);
Tex.Close();
}
catch
{ }
}
and call this method in Override function like ->
public override void Uninstall(IDictionary savedState)
{
try
{
base.Uninstall(savedState);
Log("Omg :O it works !");
}
catch(Exception ex)
{
Log(ex.Message.ToString());
}
}
At lastly Windows msi ...is not so bad ..Just dont call it rubbish Plz ..:)
Got the same issue. Read the answers here, but at first sight misunderstood the helpful answer from dynaclips.
Did you include the output of your installer code in the Code Actions
tab of the installer?
So here to make it more clear, screenshots...
And finally here the same overrides but in VB.net
Public Class Installer1
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
End Sub
<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
YourCustomInstallAction2BeRenamed()
End Sub
<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
MyBase.Commit(savedState)
End Sub
<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Rollback(ByVal savedState As System.Collections.IDictionary)
MyBase.Rollback(savedState)
YourCustomRollbackAction2BeRenamed()
End Sub
<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
MyBase.Uninstall(savedState)
YourCustomDeleteAction2BeRenamed()
End Sub
I solved this by setting the 'InstallerClass' property of my custom action to False.
I had the same issue here... hurt my head to find out why!!! It turns out though that my install project had the Primary Output of the service set to the "Release", while i was making alterations in the project to the Installer in "Debug". The moment I set them to be the same, my MessageBoxes popped up to show the code was being executed...
.. you can update your project to a much neater solution now :)
I've created an installer project for an wpf application, similar to your setup, see here, the problem described there is less important for this topic.
Nevertheless, I encountered the same problem as you described. I've
placed that installer class in the visual studio installer project
which prevents the class from execution. Everything worked well
whenever the installer class was put into the main application.
I stopped using these rubbish msi's and created a zip + cmd script instead. Strongly recommended, took me 10 times less to set up and actually works.