Add Custom action to VS 2008 Setup project - c#

Im using VS 2008 and I have created an application and Setup file using C#. The setup file contain only standard setup interfaces provide by visual studio 2008. I need to check windows registry and get some folder path and copy some files to my application folder while installation. Simply I need to add custom code while installation.
Standard interfaces.
Welcome
Installation Folder
Confirm Installation
Progress
Finished I need.
Welcome
Installation Folder
Confirm Installation
Progress
MY Custom ACTION INTERFACE
Finished
MY Custom Action performs the below action.
Ex: Get registry path.
object test= Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Kofax Image Products\\Ascent Capture\\3.0"
,"ExePath",null)
If(test!=null)
{
///Copy some files to my application folder from test path.
}
How can I do that?

You can always create your own custom action (based on existing panels for the UI)
Take a look at Scott's post entry on the subject
you can find there how to create a Setup project and add a custom action to it.
I hope it helps.

You could add a custom action, although you wouldn't have an interface in the setup for it. It is "just" code.

Related

How to create an installer for a web service without a user interface?

I have created a Web service. I need to add the ability to install it from the command line.
I created the installer for the web service like this:
I created a new Web Setup Project and added my web service to it. An installer user interface has been automatically created. It included a form for entering the parameters "Site", "Virtual directory" and "Application Pool". I added another form for typing two text parameters. Then I created a new project and called it "Deployment". In this project, I created the class "InstallAction". In it, I redefined the Install method to process my text parameters.
Now I need to add the ability to run the installer from the command line (Cmd.exe). The user interface should not be displayed! All parameters (including "Site", "Virtual directory" and "Application Pool") should be passed as parameters to the command. How to do this?
VS Setup Projects: Visual Studio Setup projects are limited. There are many alternative MSI tools. WiX is free and open source. Advanced Installer has great IIS features.
Parameters: I just commented on setup parameters in another question. Essentially your fields in your dialogs should have PUBLIC properties assigned to them (only PUBLIC - or UPPERCASE properties can be set at the command line). You must also mark these properties secure by adding them to the SecureCustomProperties list.
These pre-existing answers contain more detailed descriptions of how to deal with parameter passing:
How to make better use of MSI files
Parameterizing an MSI setup (just overview)
Mock-Up: for your case, maybe something like this:
msiexec.exe /i setup.msi SITE="mysite.com" VIRTUALDIR="mysite.com" APPPOOL="mysite.com" /qn

Creating a C# installation package that backs up the previous version before updating.

I am trying to create an installation program that will backup the previous version of a C# program before updating it. I'm using VS 2015, and have looked at the installer, advanced installer and InstallShield LE. I don't really know what I'm looking at, how to use custom actions, pretty much anything. Any advice or help would be appreciated.
Let me explain a few things first.
Backing up the previous version
Firstly,you need to identify your current application's installation folder.You can create a registry key to save where the application is installed(You need to do this in the first-time installer of your application).For that you can use Registry.LocalMachine.CreateSubKey(#"SOFTWARE\ProductName\appPathHere").Then,in your new installer,you can read the registry key to get the path of the application.Then,what you can do is create a ZIP of that path/folder.For that you can use :
System.IO.Compression.ZipFile.CreateFromDirectory(pathofApp, zipFilePath);
This will backup the current application.You can even modify the file type/extension to give it your custom type/extension.
Installing the application
Read the registry key to get the path of the installed file.Delete it using System.IO.Directory.Delete(path, true).You can ZIP all your files and then make your installer extract it to the specific location.You can simply use :
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractPath);
Creating the installer
I suggest you create a winform or WPF application,design the UI and implement the above methods.
This is not the ideal way but it will give you an idea on how to get it done with basic knowledge.Hope it helps you

How to implement Setup and Deployment project with Custom Actions

My Setup and Deployment project will copy both MyClient.exe, MyClient.Config files to the appropriate directories using the Setup.msi file.
I am trying to enhance the Setup.msi project so that user can enter the configuration values at run time and the setup program can update the file MyClient.Config. I have created a new project and added a windows Form in it with edit boxes. The project will create an application named Helper.exe
I followed the below link and implemented the Custom Actions functionality.
link
But the issue is Setup.msi is always starting the MyClient.exe instead of Helper.exe during the deployment.
Thanks in advance for your help
I'd suggest either using a different tool (this project type is removed from VS2012 and exposes very little of Windows Installer) or move the requirement from the installer to the application (first run configuration).

"User's Application Data Folder"; Is it possible to force between SpecialFolder.ApplicationData and SpecialFolder.LocalApplicationData

I have an application that needs to run at normal privileges. So it gets installed in Environment.SpecialFolder.ProgramFiles, but stores conf/logging/history details in Environment.SpecialFolder.LocalApplicationData.
The problem is that in the Setup/Deploy project, in the File System section I don't get to distinguish between ApplicationData (roaming) or LocalApplicationData, only "User's Application Data Folder," which could be either depending who installs it on what machine.
Is it possible to force "User's Application Data" to be one or the other?
MSI does support local application data folder. If you're talking about a Setup and Deployment project, maybe switching to another installer framework like WiX might be in order. (Setup and Deployment no longer exists in Visual Studio 2012 anyway). WiX has a tool called Dark that will convert an MSI to WiX XML files so you can simply edit them or add to them quickly and easily.
The Setup Project has made a comeback in visual Studio 2015.
The following works with VS 2015:
In file system view, add a special folder of type 'Custom'.
In the properties of this folder, set the following values:
Name : Local App data folder
AlwaysCreate : True
Condition : (leave empty)
DefaultLocation : [LocalAppDataFolder]
Property : SOMEPROPERTYNAME
The magic happen thanks to DefaultLocation property value: [LocalAppDataFolder].
I suppose any system folder variable as defined in the following link should work:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx#system_folder_properties

Adding folder navigation to an msi

I am creating an MSI package for a windows service, untill recently i have always just performed the minimum using the installer class and then manually edited the app.config file afterwards. However, i need to make it easier for the users to carry out an installation themselves and this has meant replacing manual configuration with prompts at install.
I have managed to add a custom action to display a textbox and prompt for a folder destination, as well as ammending the installer to create the folder using the filepath entered into the text box, but i would prefer it if the filepath could be selected by browsing to the folder.
Can anyone suggest a good tutorial or steps to do this, as i am struggling.
Thank you
This would mean a redo, but you could use WiX to build your installer.
It has built in support for everything you need, and I don't think you would need any custom actions at all (unless there is something special you don't mention).
It does have a bit of a learning curve, however. Even if you don't go with it this time, it would be worth looking into for a new project.

Categories

Resources