Skip to content

Commit

Permalink
Update empty value in XML Variable substitution (#6367)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent1173 authored Feb 6, 2018
1 parent c22e6c7 commit 5af0ed1
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 39
"Patch": 40
},
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 39
"Patch": 40
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down
3 changes: 2 additions & 1 deletion Tasks/Common/webdeployment-common/Tests/L1XmlVarSub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ async function xmlVarSub() {
'ParameterConnection': 'New_Connection_String From xml var subs',
'connectionString': 'replaced_value',
'invariantName': 'System.Data.SqlServer',
'blatvar': 'ApplicationSettingReplacedValue'
'blatvar': 'ApplicationSettingReplacedValue',
'log_level': 'error,warning'
}

var parameterFilePath = path.join(__dirname, 'L1XmlVarSub/parameters_test.xml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="rmappname" value="true"/>
<add key="log_level" value="" />
</appSettings>
<applicationSettings>
<myCustomSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="rmappname" value="true"/>
<add key="log_level" value="error,warning" />
</appSettings>
<applicationSettings>
<myCustomSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,28 @@ function updateXmlNodeAttribute(xmlDomNode, variableMap, replacableTokenValues):

if(variableMap[attributeNameValue]) {
var ConfigFileAppSettingsTokenName = ConfigFileAppSettingsToken + '(' + attributeNameValue + ')';
tl.debug('Updating value for key=' + attributeNameValue + 'with token_value: ' + ConfigFileAppSettingsTokenName);

if(xmlDomNode.getAttr(attributeName)) {
let isValueReplaced: boolean = false;
if(xmlDomNode.getAttr(attributeName) != undefined) {
tl.debug('Updating value for key= "' + attributeNameValue + '" with token_value: ' + ConfigFileAppSettingsTokenName);
xmlDomNode.attr(attributeName, ConfigFileAppSettingsTokenName);
isValueReplaced = true;
} else {
var children = xmlDomNode.children;
for(var childNode of children) {
if(varUtility.isObject(childNode) && childNode.name == attributeName) {
if (childNode.children.length === 1) {
tl.debug('Updating value for key= "' + attributeNameValue + '" with token_value: ' + ConfigFileAppSettingsTokenName);
childNode.children[0] = ConfigFileAppSettingsTokenName;
isValueReplaced = true;
}
}
}
}

replacableTokenValues[ConfigFileAppSettingsTokenName] = variableMap[attributeNameValue].replace(/"/g, "'");
isSubstitutionApplied = true;
if(isValueReplaced) {
replacableTokenValues[ConfigFileAppSettingsTokenName] = variableMap[attributeNameValue].replace(/"/g, "'");
isSubstitutionApplied = true;
}
}
}
var children = xmlDomNode.children;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 32
"Patch": 33
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 32
"Patch": 33
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down

0 comments on commit 5af0ed1

Please sign in to comment.