Custom deployment even possible?

G

Gene

I would like to know if the following is even possible with the visual
studio.net Setup and Deployment project.

1. During the deployment after creation of application directory the
setup needs to prompt user to select another location to send a data
file elsewhere on target machine (with ability to create this
directory).


2. After that this secondary location selected/created by the user,
this location needs to be inserted into an XML files which was earlier
placed in the application directory.


Thanks
 
D

Dave Sexton

Hi Gene,

I believe so. Here's a quick rundown of how you can accomplish those tasks.

[User Interface Editor]
1. Open the "User Interface Editor" (one of the buttons that appear on top of the Solution Explorer when you have the Setup Project
file selected) and add another dialog to the setup wizard, such as Textboxes (A). I recommend placing it before the "Confirm
Installation" screen. Note the name you assign to the textbox in the Properties Window, for instance Edit1Property=MYDATAFILE,
because you'll need to bind this property to an argument that will be sent to your custom installer class.

[Installer Class]
2. Add a class library to your project, if one doesn't already exist that will ship with the product, and add a new "Installer
Class" file. Here you can override some methods that allow you to retrieve arguments and perform work during installer events.
You'll probably want to override the OnCommitted method to ensure that all of the files necessary to do work have been copied to the
application directory. Use this class to copy the data file from the installation directory to the directory they have chosen in
your custom dialog interface and to modify the xml file. The class can be implemented in any .NET language. To get the location
that the user selected, which your class needs to do its work, you can access the InstallContext.Parameters property. To get your
parameter in that property see the next step.

[Custom Actions Editor]
3. Open the "Custom Actions Editor" and add your class assembly reference as a custom action. The installer will load all of the
Installer Classes in your assembly as part of the installation. Under the Commit folder (the folder you choose depends on the event
you are handling), select your assembly in the Custom Actions Editor and look at the Properties Window. Make sure Installer Class
is set to true. Set CustomActionData to something like this, /MyDataFile="[MYDATAFILE]", where MYDATAFILE is the name of the
TextBox in which the user entered the location and you want to pass into your custom installer class. Access the property like
InstallContext.Properties["MyDataFile"].

FYI, I remember having trouble with variables that represented physical path information that last time I did something like this.
If you have trouble as well there are plenty of resources on the web that explain the property syntax. Also, the CustomActionData
field in general I remember being a bit stubborn in terms of its syntax.

Windows Installer Property Reference on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/property_reference.asp

Windows Installer Guide on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/property_reference.asp

GL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top