WIX Property as Integer

2019-07-05 05:23发布

问题:

I am trying to set a a property to configure the IIS:Website ConnectionTimeout value on a new website that gets created during setup.

However I am unable to, as the value for ConnectionTimeout must be an integer, not string.

In my product.wxs I have the following:

<Control Id="IisConnectionTimeoutLabel" Type="Text" X="45" Y="164" Width="100" Height="15" TabSkip="no" Text="Connection Timeout (sec):" />
<Control Id="IisConnectionTimeoutEdit" Type="Edit" X="45" Y="176" Width="220" Height="18" Property="IIS_CONNECTIONTIMEOUT" Text="{80}" Integer="yes"  />

And in my IisConfiguration.wxs I have the following:

<Property Id="IIS_CONNECTIONTIMEOUT" Value="300" />
<iis:WebSite Id="EersWebsite" Description="[IIS_WEBSITENAME]" ConfigureIfExists="yes" Directory="WEBINSTALLDIR" DirProperties="EersWebsiteDirProperties" ConnectionTimeout="[IIS_CONNECTIONTIMEOUT]">

When I build the project I get the following:

The 'ConnectionTimeout' attribute is invalid - The value '[IIS_CONNECTIONTIMEOUT]' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:nonNegativeInteger' - The string '[IIS_CONNECTIONTIMEOUT]' is not a valid Integer value.

The iis:WebSite/@ConnectionTimeout attribute's value, '[IIS_CONNECTIONTIMEOUT]', is not a legal integer value. Legal integer values are from -2,147,483,648 to 2,147,483,647.

Thanks in advance

回答1:

As the error message states, the value of the <iis:WebSite>'s ConnectionTimeout attribute expects the integer value. The nonNegativeInteger is not a Formatted type, which knows how to extract values out of properties provided in square brackets.

Hence, I don't think you have a way here apart from providing the hard-coded value...

Alternatively, you can create a custom action, which calls for appcmd.exe, and provide the required timeout value in the command-line, and schedule this action deferred after ConfitureIIs... But the efforts seem much bigger than the benefit...



标签: wix wix3.6