all groups > dotnet setup > march 2006 >
You're in the

dotnet setup

group:

want to get app.path


want to get app.path Vivek Thakur
3/31/2006 7:42:02 AM
dotnet setup:
hi,

i have a setup project and have a custom install class where i have this
method wich tries to find a file named X.txt which is in the same folder as
the current msi (wich i double clicked).

now i want to copy this X.txt to a location in C:\. For that i created the
custom install action class and wrote a method, but i cant access the current
directory if i use application.path or other methods to get the current
directory. it always give me c:\windows\system32, which i think is logical as
my setup calls msiexec.exe which is in the windows\system32 folder.

is there any way to know where my msi exe is?
--
Vivek Thakur (MCP)
Re: want to get app.path Phil Wilson
4/1/2006 2:03:32 PM
If you've installed the file in the application folder in the setup project,
this is identified by the TARGETDIR property. So pass [TARGETDIR] into your
custom action (via CustomActionData) and it will be the path to your
directory.
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

[quoted text, click to view]

Re: want to get app.path Vivek Thakur
4/3/2006 1:02:04 AM
Phil,

thanks for yr response, but i cant use targetdir here as i want to knw the
path *before* i have installed my app. Also, its like, i have to read some
files from the folder *where my setup is present*, and not from where it wud
get installed. But i cant use app.path as it gives me the path of msiexec in
system32 folder.

please advise some way.

thanks,
--
Vivek Thakur (MCP)
www.vivekthakur.com


[quoted text, click to view]
Re: want to get app.path Phil Wilson
4/3/2006 12:34:29 PM
I think you're saying that you want to copy some files that are in the same
directory as your MSI file. If so, pass [SourceDir] into your
CustomActionData - that's the location of your MSI file.
--
Phil Wilson [MVP Windows Installer]
----
[quoted text, click to view]

Re: want to get app.path Vivek Thakur
4/3/2006 12:50:02 PM
Phil,

thanks a lot!! sometimes solutions can be so simple..but i am wondering why
isnt this documented anywhere.?? i did alot of rnd for this and didnt get
any useful thing..i got targetdir and assemblypath parameters but not
sourcedir..

anyways is shud ve used my brains..lol..

thanks a lot once again.,.,
--
Vivek Thakur (MCP)
www.vivekthakur.com


[quoted text, click to view]
Re: want to get app.path Phil Wilson
4/4/2006 7:06:57 PM
Visual Studio setup projects are Windows Installer setups, and the
properties you can use are listed here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/property_reference.asp?frame=true
--
Phil Wilson
[Microsoft MVP-Windows Installer]

[quoted text, click to view]

Re: want to get app.path Russell Stevens
4/6/2006 2:52:35 PM
Phil,

In another post you write

*********
The difficulty is when you try to add [TARGETDIR] as well it no longer
works. A CustomActionData that says /src=[SourceDir] /dst=[TARGETDIR] fails
with the FileNotFoundException. The issue seems to be that internally, the
project is generating a Windows Installer custom action that calls the
embedded InstallUtil DLL, passing:
/installtype=notransaction /action=install /LogFile= /src=[SourceDir]
/dst=[TARGETDIR] "[#_01E5F33094CF446280D30C8F055503CE]" "[VSDFxConfigFile]"

What happens is the the /src and /dst specs are in the middle of a logfile
specification, which breaks.
***************

Of course, if you want to copy files from the source to the target, you
need to know both at the same time. One workaround that seems to work;

1. Do the normal [TARGETDIR] custom action in the override for the install
class. While you are in there you can do your normal stuff.

2. In the Registry section, write the value of the [TARGETDIR] to the
registry (create a new key for your app).

3. Add another custom action for the commit phase to get the [SourceDir]

4. In the override for the commit class retrieve the [TARGETDIR] from the
registry, get the [SorceDir] from argument parameters. You now have
everything you need to copy stuff from the msi source folder to the target
folder. This is done in the commit phase instead of the install phase but
who cares after wasting all this time trying to figure out how to do it at
all <g>.

This works but why does Microsoft make something that should be trivial so
complicated <g>. Note the [SourceDir] only has a single "\" in the front if
the source is a UNC path - just another gotcha.....

Re: want to get app.path Phil Wilson
4/9/2006 11:22:07 AM
It's my impression that a lot of people have started using Visual Studio for
setups and (because of the .NET association) are writing custom actions in
managed code. People who have been building MSI setups for years have been
writing C++ custom actions because Windows Installer supports them natively.
Managed custom actions are supported by a shim Dll that processes
CustomActionData and parses it into context in installer classes. If I ask
people why they want to have all that extra complication in their setups
it's usually because they don't want to learn C++ or go back to it, but the
issues you're having are a result, and this kind of thing:
http://support.microsoft.com/default.aspx?scid=kb;en-us;555184
http://support.microsoft.com/default.aspx?scid=kb;en-us;906766

See also http://www.installsite.org/pages/en/msifaq/a/1044.htm

--
Phil Wilson
[Microsoft MVP-Windows Installer]

[quoted text, click to view]


AddThis Social Bookmark Button