What does square brackets [ ] syntax mean in WiX

2019-02-15 03:23发布

问题:

I'm creating an installer for IIS website using WiX toolset and using this manual. I've came across following syntax

<iis:WebSite Id="DemoWebsiteWebsite" Description='Demo Website' Directory='INSTALLFOLDER' AutoStart='yes' StartOnInstall='yes'>
  <iis:WebAddress Id="AllUnassigned" Port="80" />
  <iis:WebApplication Id="DemoWebsiteApplication" Name="[DemoWebsiteWebsite][WEBSITE_ID]" WebAppPool="DemoWebsiteAppPool"></iis:WebApplication>
</iis:WebSite>

I'm confused by the [] syntax and the way website id is used here. I need to use some custom values entered by user for that. So I have following questions:

  1. What does the [] syntax mean in WiX? How it is related with the $() syntax that used to access the defined value?
  2. Is there any additional meaning for two [] following each other like here [DemoWebsiteWebsite][WEBSITE_ID]?
  3. Why the WebSite Id is used in [DemoWebsiteWebsite] expression? Is that just a coincidence or naming convention?
  4. What are the allowed values to be used inside []? Is there any kind of list for them?
  5. Where can I find additional info about this syntax and cases it is used for?

回答1:

This is the way that Windows Installer properties are resolved to the actual values. If you entered a property called WEBSITE into an MSI dialog you'd get that resolved to the actual value by putting it in square brackets. That's why you see things like [TARGETDIR], [SourceDir] and so on. The syntax is used in most tools that generate MSI files because it's a Windows Installer thing.

This is the doc link, it's all hidden here:

Formatted Windows Installer

So 1 - they are properties in the MSI file, either standard Windows Installer properties or user-created ones:

Property Reference

and 2, they are just two properties concatenated. They are case-sensitive so don't be sloppy with the case. The other points should be clear after understanding that they are installer properties.

The $() values in WiX source are compile time - they resolve at build time to actual values. The [] values resolve at install time.