Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5976859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:17:17+00:00 2026-05-22T21:17:17+00:00

I would like to keep my top level .wxs DRY while building 32 and

  • 0

I would like to keep my top level .wxs DRY while building 32 and 64 bit installers. I am using the -arch argument to candle.exe to control what default installer architecture is getting built.

The wall I am hitting right now is that it appears the ProgramFilesFolder is different between 32 and 64bit (ProgramFiles64Folder) architectures. Here is my first attempt to work around:

<?if $(sys.BUILDARCH)=x64 ?>
<Directory Id='ProgramFiles64Folder' Name='PFiles'>
<?else ?>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<?endif ?>
    <Directory Id='the-rest' Name="Company Name">
...

I tried this with an error. Apparently the XML validation is fired before the preprocessor is evaluated. When I manually change to use ProgramFiles64Folder my build works.

I tried to go down the DirectoryRef route without success. Any suggestions on getting this to work without doing a sed replace within the .wxs file?

Note: I tried this in Wix 3.5 and 3.6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:17:18+00:00Added an answer on May 22, 2026 at 9:17 pm

    Rather than conditionally including the opening Directory elements (which invalidates the XML), conditionally set preprocessor variables which are used as directory names, as @Daniel Pratt’s comment refers to. Similarly, having a “yes/no” variable conditioned on platform makes it easy to set up 64 bit components, registry searches, etc.

    Defining the variables

    (From this answer)

    <?if $(var.Platform) = x64 ?>
      <?define ProductName = "Product Name (64 bit)" ?>
      <?define Win64 = "yes" ?>
      <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
    <?else ?>
      <?define ProductName = "Product Name" ?>
      <?define Win64 = "no" ?>
      <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
    <?endif ?>
    

    $(var.Platform) is built-in, but its value is used to define custom variables $(var.ProductName), $(var.Win64) and $(var.PlatformProgramFilesFolder).

    Using the variables

    You can either use preprocessor <?if directives to test variables’ values (as is done with $(var.Platform) when defining the custom variables above) or have the preprocessor insert variables’ values into XML attribute or element values. Couple of examples:

    32/64-bit components

    <Component Id="..." Win64="$(var.Win64)">
       ...
    </Component>
    

    This will produce warnings in the Visual Studio WiX editor about $(var.Win64) not being one of the allowable attribute values (yes/no) but these can be safely ignored, because the preprocessor will have substituted an appropriate value by the time the compiler gets hold of it.

    32/64 bit Program Files directory

    <Directory Id="$(var.PlatformProgramFilesFolder)">
      ...
    </Directory>
    

    Update to handle separate 32/64 bit product codes

    In response to rharrison33’s comment asking how to handle the requirement for different product codes (or pretty much anything) in the 32 and 64 bit installers (assuming you can’t/don’t want to auto-generate them):

    • Pass separate product codes to candle as preprocessor variables, on the command line or using a response file:
    candle <all other flags> -d ProductCode32=<guid1> -d ProductCode64=<guid2>
    
    • Add a product code as one of your architecture-dependent preprocessor variables, and set it to the appropriate input variable:
      • In the 32-bit <?if ?> branch: <?define ProductCode = "$(var.ProductCode32)" ?>
      • In the 64-bit <?if ?> branch: <?define ProductCode = "$(var.ProductCode64)" ?>
    • Refer to $(var.ProductCode) in Product/@Id.

    Made this CW because Daniel’s link answers the question and has a lot more great info besides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like to keep my code as DRY as possible and would like to
I would like to be able to keep the top navigation bar on my
I would like to keep the overhead at a minimum. Right now I have:
I would like to keep a static counter in a garbage collected class and
I would like to keep a list of a certain class of objects in
I would like to keep model binding when doing ajax calls from my view.
I would like to keep an item selected, on a ListView, when the user
I currently have a controller were I would like to keep track of logging
I have a small JSF app and would like to keep some state on
I'm playing with bencoding and I would like to keep bencoded strings as Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.