FileTransform@1 - File transform v1 task

Use this task to replace tokens with variable values in XML or JSON configuration files.

Syntax

# File transform v1
# Replace tokens with variable values in XML or JSON configuration files.
- task: FileTransform@1
  inputs:
    folderPath: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #enableXmlTransform: false # boolean. XML transformation. Default: false.
    #xmlTransformationRules: '-transform **\*.Release.config -xml **\*.config' # string. Optional. Use when enableXmlTransform == true. Transformation rules. Default: -transform **\*.Release.config -xml **\*.config.
  # Variable Substitution
    #fileType: # 'xml' | 'json'. File format. 
    #targetFiles: # string. Optional. Use when fileType = xml || fileType = json. Target files.
# File transform v1
# Replace tokens with variable values in XML or JSON configuration files.
- task: FileTransform@1
  inputs:
    folderPath: '$(System.DefaultWorkingDirectory)/**/*.zip' # string. Required. Package or folder. Default: $(System.DefaultWorkingDirectory)/**/*.zip.
    #enableXmlTransform: false # boolean. XML transformation. Default: false.
    #xmlTransformationRules: # string. Optional. Use when enableXmlTransform == true. Transformation rules. 
  # Variable Substitution
    #fileType: # 'xml' | 'json'. File format. 
    #targetFiles: # string. Optional. Use when fileType = xml || fileType = json. Target files.

Inputs

folderPath - Package or folder
string. Required. Default value: $(System.DefaultWorkingDirectory)/**/*.zip.

The file path to the package or a folder.

Variables are Build and Release. Wildcards are supported.

For example, $(System.DefaultWorkingDirectory)/**/*.zip.


enableXmlTransform - XML transformation
boolean. Default value: false.

Config transforms will be run prior to the Variable Substitution.

XML transformations are supported only for Windows platform.


xmlTransformationRules - Transformation rules
string. Optional. Use when enableXmlTransform == true. Default value: -transform **\*.Release.config -xml **\*.config.

Provides a new line separated list of transformation file rules using the syntax:

-transform <pathToTransformFile> -xml <pathToSourceConfigurationFile>.


xmlTransformationRules - Transformation rules
string. Optional. Use when enableXmlTransform == true. Default value: -transform **\*.Release.config -xml **\*.config\n-transform **\*.$(Release.EnvironmentName).config -xml **\*.config.

Provides a newline-separated list of transformation file rules using the syntax:

-transform <pathToTransformFile> -xml <pathToSourceConfigurationFile>.


fileType - File format
string. Allowed values: xml, json.

Provides the file format on which the substitution is perfformed.

For XML, variables defined in the build or release pipelines will be matched against the key or name entries in the appSettings, applicationSettings, and connectionStrings sections of any config file and parameters.xml. Variable Substitution is run after config transforms.

To substitute JSON variables that are nested or hierarchical, specify them using JSONPath expressions.

For example, to replace the value of ConnectionString in the sample below, you need to define a variable as Data.DefaultConnection.ConnectionString in the build or release pipeline (or release pipeline's environment).

{
  "Data": {
    "DefaultConnection": {
      "ConnectionString": "Server=(localdb)\SQLEXPRESS;Database=MyDB;Trusted_Connection=True"
    }
  }
}

Variable Substitution is run after configuration transforms.

Note: Only custom variables that are defined in build/release pipelines are used in substitution. Default/system defined pipeline variables are excluded. If the same variables are defined in the release pipeline and in the stage, then the stage variables will supersede the release pipeline variables.


targetFiles - Target files
string. Optional. Use when fileType = xml || fileType = json.

Provides a newline-separated list of files to substitute the variable values. File names are to be provided relative to the root folder.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

There is a newer version of this task available at FileTransform@2.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version All supported agent versions.
Task category Utility