Welcome to MSDN Blogs Sign in | Join | Help

WiX: Functional Preprocessing

The preprocessor in WiX has a new feature called Functional Preprocessing. It is a way for WiX users to define functions that they can use in their authoring to dynamically fill in content.

 Most people who use WiX are familiar with preprocessor variables which look like:

 "$(var.VariableName)"

 The preprocessor now has support for functions in addition to variables which look like:

"$(func.FunctionName(arg1,arg2,arg3))"

While there have been no additions as of yet to the standard WiX preprocessor function library many functions have been implemented and are being used in people's preprocessor extensions. In an extension you tell the preprocessor that you would like to have all functions with a specific qualifier be handled by your extension.

Example:

Say you want to keep track of all of your component GUID's in a single file. The file has 4 pieces of data for each GUID. Id, Language, Architecture, and of course the GUID.

MyComponentId, English, Intel, 365453-34235-32525-23325345223

If you implement a preprocessor extension to handle "guid" functions and define a function called "GetGuid" that takes 3 arguments you could represent the guid in your authoring as:

"$(guid.GetGuid(MyComponentId,English,Intel))"

This function would be replaced in your authoring with "365453-34235-32525-23325345223".

 There are a lot of possible uses of this type of functionality. I'd love to hear how other people use it.

Published Friday, April 27, 2007 8:27 PM by Petermarcu
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: WiX: Functional Preprocessing

I think this is a welcom extension to WiX.

But will it be possible to make your extensions in some form of extension DLL? (Kinda plug-in)

This way it would be possible, for example, to put GUIDs in a database and you can use your extension to WiX (candle i suppose) to read the correct GUID based on the parameters in the function.

I would welcome this because i would like to store my component GUIDs per version of my product in a database so it would easy the auto generating of MSI files on a daily base with new files automatically added.

Thursday, May 10, 2007 5:45 PM by Albert van Peppen

# re: WiX: Functional Preprocessing

Yes, the correct way to implement a function is in a preprocessor extension. This would be part of the same dll that a compiler extension is implemented in. Just identify which namespaces you want the preprocessor to pass to you extension to resolve and then write your function to get the guids however you need to get them out of your system.

Would a blog entry on how to implement a preprocessor extension be helpful?

Thursday, May 10, 2007 5:53 PM by Peter Marcu

# re: WiX: Functional Preprocessing

I think this would be very usefull. It may save a lot of time if it is described.

(I think documentation will always be hard for a project like WiX, since you can write entire books about it ;) )

Monday, May 14, 2007 3:40 AM by Albert van Peppen

# re: WiX: Functional Preprocessing

nice to read about Functional Preprocessing.but can you tell me that how can i use given  command :

candle.exe [-?] [-nologo] [-out outputFile] sourceFile [sourceFile ...]

at the place of [-?] i want to use '-d' .but i am not getting exactly the use of this '-d' .

can you make me understand through an example??

Thursday, July 05, 2007 4:57 AM by Atul

# re: WiX: Functional Preprocessing

-d is used to pass variables in the "var" namespace. For example: If you pass -dTEST=test on the command line. You could use "$(var.TEST)" in your authoring and it would be replaced by the preprocessor to equal "test" before your authoring is sent to the compiler.

Friday, July 20, 2007 2:47 AM by Petermarcu

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker