PDA

View Full Version : Suite properties and passing properties to packages from the command line



kmoulton
10-21-2011, 01:54 PM
I have some exe installation packages that behave differently based on the command line parameters passed to them.

The command line parameter settings are based on information obtained through previous package installations. Is there a way to communicate information obtained in a previous package to the current package from the command line.

Is there a way to change suite properties and use these from the package command line.

I don't want to create separate packages for different command line parameters. I suppose I could write something to the registry and use it as a detection type of condition, but it would be nice if we could change Suite properties during the install and use them from the package command line.

Any suggestions?

MichaelU
10-21-2011, 06:18 PM
Hmm. There's no good feedback mechanism like this today. You can certainly set properties in the UI and pass them to packages to avoid having to define multiple packages for separate command lines. However I don't think there are any hooks to retrieve information either from the first package, or off the machine after it is installed, to store into a property and use in the second package's command line.

What sort of information are you hoping to acquire (perhaps something like a return code, registry entry, or a file path)?

kmoulton
10-21-2011, 07:01 PM
For example, I would like to know if I am running on a terminal server. I can get this information from some of the Windows Installer properties, but I don't know a way to pass this to the package. I could certainly write it to the registry, and read it back, but that seems more like a hack.

In one of the cases that I am concerned about, it is much more complex then the example above. I need to pass to an exe package a command line argument that specifies if I want to install as a service or an app. To determine the correct value to pass, I need to determine if I am running on a terminal server, what particular application I am going to run (which will probably require a special custom action and some specific MSI searches), and if my platform is 64-bit. It would be nice if I could somehow set a property based on what I determined in my previous package that could be passed on the command line to a future exe package.

Would a suite property be available on the package command line? Can you change the value of a suite property at run time?

Thanks in advance,

--Kim

MichaelU
10-24-2011, 11:03 AM
I'll answer these in reverse. Suite properties are absolutely available for use on a package's command line - just include references to them like [PropertyName]. Suite properties can be modified at run-time; typically this will be through controls on the UI. And there's another way.

In the XML of the suite project, we have the concept of conditional definitions of properties. We just haven't figured out how best to represent this in the IDE; it will only show one value, and won't mention that there's a condition yet. Instead of just <SetProperty Name="propertyName" Value="propertyValue/> you can actually nest a condition inside a <When/> element inside this element. You can also set the same property multiple times; the last one whose condition is true will "win". So for example to set a property that reflected which architecture the suite is running on, it might look like this.
<SetProperty Name="Architecture" Value="unknown"/>
<SetProperty Name="Architecture" Value="x64">
<When>
<Any>
<Platform Architecture="x64"/>
</Any>
</When>
</SetProperty>
<SetProperty Name="Architecture" Value="x86">
<When>
<Any>
<Platform Architecture="x86"/>
</Any>
</When>
</SetProperty>

And finally, to check if you're on a terminal server, you will probably need to write a custom condition (our Platform condition doesn't appear to cover this, but perhaps a Registry checking condition might). Custom conditions depend on some changes coming with in SP1, and we'll have more information on that part after the release.

Once that's all in place, do you think that will cover your scenario?

kmoulton
10-24-2011, 05:11 PM
It will help to be able to use Suite properties on the command line. That is a nice feature. I am also interested in hearing more about custom conditions.

As far as conditional definitions of properties, I am not exactly sure how that will work with what I am trying to do. What I would like to do is define a Suite property in the property manager and then be able to change that property during the install if I determined that it should change.

However, to determine if the property should change may take another MSI with custom actions and MSI searches to actually make the determination.

If I could change the value of the property then I could pass it directly on the command line to the executable and things would work the way I would like them to.

The reason I wan't to do this is that I don't wan't to include an entire package twice just so I can use a different command line parameter with the executable.

Thanks,

--Kim

MichaelU
10-25-2011, 10:16 AM
There are two different extension points that we'll cover with the SP. Both of them allow you to set properties from custom code. If you just have two (or three) possible values, the condition approach I outlined above will work. However if it's something like reading a version number from a registry value or file and then passing that value on a command line, doing so will require some custom code even in the SP.

kmoulton
10-25-2011, 11:05 AM
Thanks. I will look forward to the service pack.