Detecting install folder during installation

C

Chad Smith

Hi,

I have created a .NET deployment project in Visual Studio 2003. I have
specified an entry point into my own code in this installer which launches
into the familiar:

public override void Install(IDictionary savedState)
{
Application.Run(new MyForm());
base.Install(savedState);
}

That's the background and everything works swimmingly - one thing I cannot
find anywhere is how to get the installation location at this point, for
instance if the user chooses to install to the E: drive or similiar during
the install process, how would you then find the path the user chose?

The reason I want this path is because this application is a visual studio
add-in and thus can't use System.IO.Directory.GetCurrentDirectory() later on,
yet I want to allow the user to choose where the files it uses should be
installed and be able to access those.

Any help is kindly appreciated,

Chad Smith.
 
P

Phil Wilson

Pass TARGETDIR into the custom action like this:
http://msdn.microsoft.com/library/d...intro7/html/vxgrfcustomactiondataproperty.asp

You might get some unusual things happening because what you're doing is not
supposed to be done. The architecture of MSI setups is that there is a UI
sequence and then a silent sequence running on top of the MSI Service. You
shouldn't be showing UI like this, and it might be safer to launch your app
rather than have it run on top of the MSI Service.
System.IO.GetCurrentDirectory() is just one of those things that won't be
what you expected. Do any of your users expect to be able to do a silent
install?
 
C

Chad Smith

Thank you for your reply, I'll test that now.

Users won't be running a silent install at this stage but thanks for the
pointer, I'll keep this in mind.

This goes off topic but as you mentioned it, and if you wouldn't mind helping
further; what is the .net best practice for actually launching an app from
inside a component such as this?

Many thanks again,

Chad.

Pass TARGETDIR into the custom action like this:
http://msdn.microsoft.com/library/d...intro7/html/vxgrfcustomactiondataproperty.asp

You might get some unusual things happening because what you're doing is not
supposed to be done. The architecture of MSI setups is that there is a UI
sequence and then a silent sequence running on top of the MSI Service. You
shouldn't be showing UI like this, and it might be safer to launch your app
rather than have it run on top of the MSI Service.
System.IO.GetCurrentDirectory() is just one of those things that won't be
what you expected. Do any of your users expect to be able to do a silent
install?
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

Chad Smith said:
Hi,

I have created a .NET deployment project in Visual Studio 2003. I have
specified an entry point into my own code in this installer which launches
into the familiar:

public override void Install(IDictionary savedState)
{
Application.Run(new MyForm());
base.Install(savedState);
}

That's the background and everything works swimmingly - one thing I cannot
find anywhere is how to get the installation location at this point, for
instance if the user chooses to install to the E: drive or similiar during
the install process, how would you then find the path the user chose?

The reason I want this path is because this application is a visual studio
add-in and thus can't use System.IO.Directory.GetCurrentDirectory() later
on,
yet I want to allow the user to choose where the files it uses should be
installed and be able to access those.

Any help is kindly appreciated,

Chad Smith.
 
P

Phil Wilson

It depends what your app code does. If it collects data from the user, that
should be happening in the UI sequence up front. That data typically gets
stored in properties that you define (like [TARGETDIR] is a built-in
property). If there are default values for the properties you can specify
them with a command line install:

msiexec /i <path to msi> MYPROPERTY=something

or just put the defaults in the Property table in the MSI (no VS support for
that). If you just want to run your app, it's common to trigger it off the
Finish button when you get the final dialog (no VS support for that) if
there's always a user interface. If the install is always quiet (there's a
UILevel property to tell you whether it is or not) you can just run an
executable rather than have your app running on top of the MSI Service.
Since you mentioned .NET best practice, I'll add that none of this .NET -
Windows Installer has been around since before .NET, but since VS .NET
started offering setup projects many people think that VS .NET setup
projects and Windows Installer are somehow the same thing.

--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

Chad Smith said:
Thank you for your reply, I'll test that now.

Users won't be running a silent install at this stage but thanks for the
pointer, I'll keep this in mind.

This goes off topic but as you mentioned it, and if you wouldn't mind
helping
further; what is the .net best practice for actually launching an app from
inside a component such as this?

Many thanks again,

Chad.

Pass TARGETDIR into the custom action like this:
http://msdn.microsoft.com/library/d...intro7/html/vxgrfcustomactiondataproperty.asp

You might get some unusual things happening because what you're doing is
not
supposed to be done. The architecture of MSI setups is that there is a UI
sequence and then a silent sequence running on top of the MSI Service. You
shouldn't be showing UI like this, and it might be safer to launch your
app
rather than have it run on top of the MSI Service.
System.IO.GetCurrentDirectory() is just one of those things that won't be
what you expected. Do any of your users expect to be able to do a silent
install?
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

Chad Smith said:
Hi,

I have created a .NET deployment project in Visual Studio 2003. I have
specified an entry point into my own code in this installer which
launches
into the familiar:

public override void Install(IDictionary savedState)
{
Application.Run(new MyForm());
base.Install(savedState);
}

That's the background and everything works swimmingly - one thing I
cannot
find anywhere is how to get the installation location at this point, for
instance if the user chooses to install to the E: drive or similiar
during
the install process, how would you then find the path the user chose?

The reason I want this path is because this application is a visual
studio
add-in and thus can't use System.IO.Directory.GetCurrentDirectory()
later
on,
yet I want to allow the user to choose where the files it uses should be
installed and be able to access those.

Any help is kindly appreciated,

Chad Smith.
 

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