Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I set property in Custom Action?

1,017 views
Skip to first unread message

John Roper

unread,
Nov 1, 2004, 8:10:03 AM11/1/04
to
Hi,

I have a web deployment project that also installs a web service using an
additional "Web Application Folder". The web deployment asks the user for a
port number and I'd like to install the web service to this port also. I have
a custom action (written in c#), so I could set the relevant Msi Property, if
only I knew how to do it. Can someone please enlighten me?

Conceptually I want to do:

[NEWWEBPROPERTY2PORT] = [TARGETPORT]

Thanks
John

Stefan Krueger [MVP]

unread,
Nov 1, 2004, 8:15:20 AM11/1/04
to
Call MsiSetProperty to set the property.

C# Wrappers for the Windows Installer API:
http://www.installsite.org/pages/en/msi/tips.htm#CsharpWrapper


--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

Windows Installer FAQ
http://www.msifaq.com - http://www.msifaq.de

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)


"John Roper" <John...@discussions.microsoft.com> schrieb im Newsbeitrag
news:9C870CA2-220A-4C4D...@microsoft.com...

John Roper

unread,
Nov 1, 2004, 8:31:02 AM11/1/04
to
Hi Stefan,

Thanks for the quick response. To clarify, I must:

1. Add in a wrapper library to the Msi functions (sigh).
2. Pass in the [OriginalDatabase] to my custom action in the
CustomActionData (as, say, /database="[OriginalDatabase]"
3. Extract this path using dbpath=Context.Parameters["database"];
4. Open the database using MsiOpenDatabase(dbpath)
5. Use MsiSetProperty

I must admit I'd hoped to find an easier way :-)

Best regards
John

Phil Wilson

unread,
Nov 1, 2004, 10:15:48 AM11/1/04
to
This is difficult because you have a C# Installer class custom action -
these get called indirectly via an intermediate DLL, and can receive
properties from the install through that DLL, but are a bit limited. Most
installs I've seen that create a virtual directory use the scripting model
and write a VBScript custom action. An immediate VBScript custom action can
just use Property("TARGETPORT") when creating the web site. There's an
example script here, scroll down:
http://www.installsite.org/pages/en/msi/ca.htm
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

"John Roper" <John...@discussions.microsoft.com> wrote in message
news:0E821266-62E3-40FA...@microsoft.com...

John Roper

unread,
Nov 1, 2004, 11:34:14 AM11/1/04
to
Hi Phil,

Thanks.

I've found the "Register TLB File Using VBScript", which I guess is the one
you are referring to?

I am happy to write a .vbs to set one property to be the same as another,
based on the above .vbs, but I don't know how to register the .vbs script as
a custom action in VS 2003 deployment project. Any help on this would be very
gratefully received.

Thanks
John

Phil Wilson

unread,
Nov 1, 2004, 12:55:22 PM11/1/04
to
It's the "Create Virtual Directory in IIS" topic I'm looking at, assuming
that's what you want to do.
In the Visual Studio IDE, just browse to a vbs file to use it as a custom
action.VS-generated custom actions are always deferred, so you'll need to
pass the data via CustomActionData, just using [TARGETPORT]. That
/arg=[TARGETPORT] syntax is only for C# Installer class custom actions.
--
Phil Wilson [MVP Windows Installer]
----

"John Roper" <John...@discussions.microsoft.com> wrote in message
news:4AC414B4-31A6-4507...@microsoft.com...

John Roper

unread,
Nov 2, 2004, 3:48:02 AM11/2/04
to
Hi Phil,

OK I found the one you were referring to and I can modify one of these to do
as follows:

Property("NEWWEBPROPERTY2PORT") = Property("TARGETPORT")

but I'm worried that this will happen too late to affect the installation of
my web service (NEWWEBPROPERTY2) because of what you say about deferred
actions (I'm afraid I don't know much about the windows installer).

John Roper

unread,
Nov 2, 2004, 11:57:09 AM11/2/04
to
Hi,

I'm pretty sure that this won't work, as the custom action is being called
too late in the process to affect the install of the web services.

Is there a way I can get it called earlier?

I can see that the MSI supports doing custom actions earlier, but I don't
know how to add them in VS 2003 - perhaps it isn't possible. If not, can
anyone give me a solution to my problem?

I added the .vbs script as a custom action in VS 2003 and got it called, but
Session.Property("TARGETPORT") was null and trying to set NEWWEBPROPERTY2PORT
failed.

Thanks in advance
John

John Roper

unread,
Nov 2, 2004, 1:20:02 PM11/2/04
to
Hi Stefan,

I tried your suggestion, but my custom action is being called too late. I
have changed my server to not have a web site on port 80. When I attempt to
install, I specify a valid port (say 82) and then the install of the web
service fails before my custom action is even called (this action would have
set the web service's port to 82 to match the main site's port). I am at a
loss to know how you are supposed to set up a second virtual directory within
a deployment project if there's no way to set the port parameter to something
appropriate. I assume that I'm going to have to look for a more flexible
front-end to the Windows Installer that allows me to do this.... Is that
right, or am I missing something?

Cheers
John

Phil Wilson

unread,
Nov 2, 2004, 2:03:33 PM11/2/04
to
The custom action won't be too late if it is the only thing that is
installing the virtual directory. If you expect to install files into that
directory, it will be too late because of when Visual Studio deferred custom
actions run, but if all you want to do is create a virtual directory that
has no interaction with the rest of the setup you can do it in a deferred
custom action from Visual Studio. If you want to see a property called
MYPORT in a VBScript called as a deferred custom actom action, set the
CustomActionData property to [MYPORT] and in the script use
Session.Property("CustomActionData") to get the value.

--
Phil Wilson [MVP Windows Installer]
----
"John Roper" <John...@discussions.microsoft.com> wrote in message
news:D680698F-73F7-4F84...@microsoft.com...

John Roper

unread,
Nov 3, 2004, 2:37:03 AM11/3/04
to
Hi Phil,

OK I understand the confusion. In the deployment project (in the files view)
I had added an additional "web folder" which installs my web service. This
has a Port Property which I want to change before it gets installed (and is
accessible as NEWWEBPROPERTY2PORT). There doesn't seem to be a way to do this
within the VS 2003 framework, as all the custom actions are deferred and
adding new UI dialogs doesn't seem to allow me to set this value. I'm
thinking of making a separate installer (perhaps I can do a merge module?)
that would install the web service. It's not great, but would provide the
necessary dialog to allow the port to be set by the person running the
installer. It's either that, or start trying to use something like ORCA, but
I've never used that and I don't really know how to integrate it into my
build. Or I re-write the whole installer using InstallShield....

So to summarize, I do want to install files. The VS 2003 deployment project
does this but will install them to a fixed virtual directory on a port I
specify in the deployment project (80). The deployment project will create
this virtual directory, but only on these defaults. There is no way to change
this and that's what I have been struggling to do.

Thanks for the help
John

Stefan Krueger [MVP]

unread,
Nov 8, 2004, 5:44:34 AM11/8/04
to
Yes, it looks like you are running into a limitation of VS.NET. You can find
a list of MSI authoring tools at http://www.installsite.org/go/msidev.htm

--
Stefan Krueger
Microsoft Windows Installer MVP

Please post your questions in the newsgroup or vist one of these web sites:

InstallSite - Resources for Setup Developers
http://www.installsite.org
http://www.installsite.de (GERMAN)

"John Roper" <John...@discussions.microsoft.com> schrieb im Newsbeitrag

news:EDE3BB15-6083-416B...@microsoft.com...

Phil Wilson

unread,
Nov 9, 2004, 5:02:30 PM11/9/04
to
The other thing you could look at is to use a standard setup&deployment
project to install files in the usual way, and install the web stuff with a
custom action. This is a start:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dniis/html/Autoadm.asp
There's Create Virtual Directory topic here:
http://www.installsite.org/pages/en/msi/ca.htm --
Phil Wilson [MVP Windows Installer]
----
"John Roper" <John...@discussions.microsoft.com> wrote in message
news:CEE11321-BA99-4E2B...@microsoft.com...
0 new messages