simple question: Web setup project installer. changing installation directory

M

MENTAT

Hi,

I am trying to create an installer for my web application. So I added a
web setup project to my solution (I am using VS.NET 2003). Been playing
around with it since then and it basically works.

Now, I am wondering if there is any way to change the directory that
the installer installs the files to. I want to be able to put my files
in a specified directory (user specified is good, but i don't mind
hardcoding the path either) and point my virtual directory to it.

Is there any way to do this. Right now the files are just being stored
in c:\...\inetput\wwwroot\ProjectFileName directory. I opened up the
File system editor and looked at the properties for the WebApplication
Folder. One of the properties is called property TARGETDIR. I assume
this is the property i need to change?
From what I gathered on the web and newsgroups, this property can be
accessed "programatically". Is this correct? Can anyone tell me me how
to access and set this property. As I said, Ideally I would like to
give the user the option of specifying the physical directory, but i
don't mind hardcoding that during design time either.
 
M

MENTAT

Thanks for the reply Kannan,

Yes, the articles have helped. But from what i gather the CustomAction
is executed after the installation. By this time the directory
structure has already been created. (Isn't that correct?)

Is there any way to programmatically create virtual directories. I.e
create and ordinary directory structure and point a virtual directory
to it. There are some code snippets for this floating around, but they
are all written in VB, not C#. I haven't found one in C# yet. Is the
only way to create virtual directories and configure IIS to use VB? (If
so, I might have to start learning to code in VB). Or is there a c#
option?

I read somewhere that the solution to this is to use an ordinary setup
project (not a web setup) and create the directory structure, and then
point the virtual directory to it. Is this really the best way to do
things or is there a web setup solution?

How do I get CustomAction to execute before the installation. In the
installer class there is a BeforeInstall event. Is this what I have to
use create my virtual directory programmatically (if that is the way to
go).

There seems to be a lot of bits and pieces around and related sequence
tasks to be done. So far I haven't found a good comprehensive solution.
Surely someone out there has already done this before? Just need a bit
more help piecing the puzzle together.

Thanks all in advance.


PS: I haven't been able to access Context.Parameters["INSTALLDIR"] so
far. Keeps throwing an "object reference not set to an object instance"
error during installation. And from what I gather, this is a property
that is set by the installer after installation. Not something the
CustomAction can set before installation. Am I correct?


Kannan.V said:
hi....

for reading the values from the install program, i guess u must have added
custom forms to ur install app from the setup project, in this case u have to
create a custom installer class to read the values from the installer
application and do the required job, once u have created ur installer class u
need to add this dll file as a custom action to the installer,
so when the installer runs, the code in the installer class also gets
executed.

you need to pass the parameters thro the custom action data property in the
setup app.
Ex. - /INSTALLDIR="[INSTALLDIR]"
and inside the installer class you can read the parameters as shown below.
Console.WriteLine(Context.Parameters["INSTALLDIR"].ToString());

check out these links for further reading.
http://www.c-sharpcorner.com/Code/2002/July/UseInstClasses.asp

http://msdn.microsoft.com/library/d...emconfigurationinstallinstallerclasstopic.asp

hope this helps,
Bye

Kannan.V
http://kannanv.blogspot.com



MENTAT said:
Hi,

I am trying to create an installer for my web application. So I added a
web setup project to my solution (I am using VS.NET 2003). Been playing
around with it since then and it basically works.

Now, I am wondering if there is any way to change the directory that
the installer installs the files to. I want to be able to put my files
in a specified directory (user specified is good, but i don't mind
hardcoding the path either) and point my virtual directory to it.

Is there any way to do this. Right now the files are just being stored
in c:\...\inetput\wwwroot\ProjectFileName directory. I opened up the
File system editor and looked at the properties for the WebApplication
Folder. One of the properties is called property TARGETDIR. I assume
this is the property i need to change?
be
accessed "programatically". Is this correct? Can anyone tell me me how
to access and set this property. As I said, Ideally I would like to
give the user the option of specifying the physical directory, but i
don't mind hardcoding that during design time either.
 
G

Guest

hi MENTAT,

As you have said the directory structure for the web setup projects are
created at the start of the install process, tried to play around with it,
but was not able to get a way to manipulate it.

You can programatically create directories and point to a virtual directory.
and there is no difference in using VB or C#, you must be able to do
whatever you do in VB using C#, the only difference is the syntax and a
little bit of the way they both handle things, but thats got nothing to do
with the coding or the logic part.

Yes we can use the Ordinary setup project to create folders and point to the
virtual directory.

Will post with more info once try something on my box.

PS : For websetup projects use the ["TARGETDIR"] as the parameter.

MENTAT said:
Thanks for the reply Kannan,

Yes, the articles have helped. But from what i gather the CustomAction
is executed after the installation. By this time the directory
structure has already been created. (Isn't that correct?)

Is there any way to programmatically create virtual directories. I.e
create and ordinary directory structure and point a virtual directory
to it. There are some code snippets for this floating around, but they
are all written in VB, not C#. I haven't found one in C# yet. Is the
only way to create virtual directories and configure IIS to use VB? (If
so, I might have to start learning to code in VB). Or is there a c#
option?

I read somewhere that the solution to this is to use an ordinary setup
project (not a web setup) and create the directory structure, and then
point the virtual directory to it. Is this really the best way to do
things or is there a web setup solution?

How do I get CustomAction to execute before the installation. In the
installer class there is a BeforeInstall event. Is this what I have to
use create my virtual directory programmatically (if that is the way to
go).

There seems to be a lot of bits and pieces around and related sequence
tasks to be done. So far I haven't found a good comprehensive solution.
Surely someone out there has already done this before? Just need a bit
more help piecing the puzzle together.

Thanks all in advance.


PS: I haven't been able to access Context.Parameters["INSTALLDIR"] so
far. Keeps throwing an "object reference not set to an object instance"
error during installation. And from what I gather, this is a property
that is set by the installer after installation. Not something the
CustomAction can set before installation. Am I correct?


Kannan.V said:
hi....

for reading the values from the install program, i guess u must have added
custom forms to ur install app from the setup project, in this case u have to
create a custom installer class to read the values from the installer
application and do the required job, once u have created ur installer class u
need to add this dll file as a custom action to the installer,
so when the installer runs, the code in the installer class also gets
executed.

you need to pass the parameters thro the custom action data property in the
setup app.
Ex. - /INSTALLDIR="[INSTALLDIR]"
and inside the installer class you can read the parameters as shown below.
Console.WriteLine(Context.Parameters["INSTALLDIR"].ToString());

check out these links for further reading.
http://www.c-sharpcorner.com/Code/2002/July/UseInstClasses.asp

http://msdn.microsoft.com/library/d...emconfigurationinstallinstallerclasstopic.asp

hope this helps,
Bye

Kannan.V
http://kannanv.blogspot.com



MENTAT said:
Hi,

I am trying to create an installer for my web application. So I added a
web setup project to my solution (I am using VS.NET 2003). Been playing
around with it since then and it basically works.

Now, I am wondering if there is any way to change the directory that
the installer installs the files to. I want to be able to put my files
in a specified directory (user specified is good, but i don't mind
hardcoding the path either) and point my virtual directory to it.

Is there any way to do this. Right now the files are just being stored
in c:\...\inetput\wwwroot\ProjectFileName directory. I opened up the
File system editor and looked at the properties for the WebApplication
Folder. One of the properties is called property TARGETDIR. I assume
this is the property i need to change?

From what I gathered on the web and newsgroups, this property can be
accessed "programatically". Is this correct? Can anyone tell me me how
to access and set this property. As I said, Ideally I would like to
give the user the option of specifying the physical directory, but i
don't mind hardcoding that during design time either.
 

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