After some Googling, I found out that the custom action for the Visual Studio installer might need to point to the installer class. So I created a new type class project in my solution. I deleted the class1.cs file and added the installer class to the new project with the following code (mental note: you need to use security.permissions at some point):
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Linq; using System.Diagnostics; using System.Security.Permissions; namespace AppName { [RunInstaller(true)] public partial class InstallerClass : System.Configuration.Install.Installer { public InstallerClass() { InitializeComponent(); } public override void Commit(System.Collections.IDictionary savedState) { base.Commit(savedState); System.Diagnostics.Process.Start(Context.Parameters["TARGETDIR"].ToString() + "application.exe");
After adding the InstallerClass, I right-click on the installer project and select Add> Project Output and added the installer class. Then I right-clicked on the installed project and did View> Custom Action. I added the installer class to the Install and Commit folders (if you just add it to Commit, you get an error 1001: the InstallState file could not be found. Due to the override of commit, it will only work when committing. Apparently, the InstallState created on stage 2, so if it is not in both, then it will fail).
You must add a CustomActionData entry. To do this, select "Initial Output from InstallerClass" and go to the "Initiatives" tab. Paste the following data into CustomActionData:
/TARGETDIR="[TARGETDIR]\"
After that, the application starts correctly when the installation is completed, and you can close the installation program, and not wait for the application to exit!
Just what I need. Thanks to Google for saving my bacon.
The only problem I noticed was the installation, which now creates several .tmp files and the .InstallState file in my ApplicationFolder. I am wondering if there is anything extra that needs to be added to the installer class to get rid of these useless files?
It turned out how to get rid of temporary files. Updated code using Dispose ().
source share