Note: This API documentation is for FAKE version 4. The migration API documentation can be found here. The API documentation for the new fake 5 modules can be found here

ConfigurationHelper

Contains functions which allow to read and write config files.

Functions and values

Function or valueDescription
applyXslOnConfig xsl fileName
Signature: xsl:string -> fileName:string -> unit

Applies a Xsl Stylesheet to a config file and writes it back.

Parameters

  • xsl - The Xsl stylesheet to apply.
  • fileName - The file name of the config file.

Sample

1: 
applyXslOnConfig (navServicePath @@ DEV.xsl) (navServicePath @@ "CustomSettings.config")
readConfig(fileName)
Signature: fileName:string -> XmlDocument

Reads a config file into an XmlDocument.

Parameters

  • fileName - The file name of the config file.
updateApplicationSetting(...)
Signature: fileName:string -> settingName:string -> value:string -> unit

Reads a config file from the given file name, replaces the Application Setting (as opposed to AppSetting) value and writes it back.

Parameters

  • settingName - The ApplicationSetting name for which the value should be replaced.
  • value - The new ApplicationSetting value.
  • fileName - The file name of the config file.

Sample

1: 
updateApplicationSetting "DatabaseName" targetDatabase (navServicePath @@ "CustomSettings.config")
updateAppSetting key value fileName
Signature: key:string -> value:string -> fileName:string -> unit

Reads a config file from the given file name, replaces the app setting value and writes it back.

Parameters

  • key - The AppSettings attribute key name for which the value should be replaced.
  • value - The new AppSettings attribute value.
  • fileName - The file name of the config file.

Sample

1: 
updateAppSetting "DatabaseName" targetDatabase (navServicePath @@ "CustomSettings.config")
updateConfig(...)
Signature: xpath:string -> attribute:string -> value:string -> config:XmlDocument -> XmlDocument

Reads a config file from the given file name, replaces an attribute using the given xPath and writes it back.

Parameters

  • xpath - An XPath term which can be used to replace the attribute.
  • attribute - The attribute name for which the value should be replaced.
  • value - The new attribute value.
  • config - The XElement representing the config.
updateConfigSetting(...)
Signature: fileName:string -> xpath:string -> attribute:string -> value:string -> unit

Reads a config file from the given file name, replaces an attribute using the given xPath and writes it back.

Parameters

  • fileName - The file name of the config file.
  • xpath - An XPath term which can be used to replace the attribute.
  • attribute - The attribute name for which the value should be replaced.
  • value - The new attribute value.
updateConnectionString(...)
Signature: connectionStringKey:string -> value:string -> fileName:string -> unit

Reads a config file from the given file name, replaces the connection string value and writes it back.

Parameters

  • connectionStringKey - The connection string key name for which the value should be replaced.
  • value - The new connection string value.
  • fileName - The file name of the config file.
writeConfig fileName config
Signature: fileName:string -> config:XmlDocument -> unit

Writes an XmlDocument to a config file.

Parameters

  • fileName - The file name of the config file.
  • config - The XmlDocument representing the config.