From bfb8349e0443a3e2d40e93b9a29d822994352043 Mon Sep 17 00:00:00 2001 From: Arjun Gupta Date: Wed, 24 May 2017 17:27:29 +0530 Subject: [PATCH] Users/arjgupta/errortowarning master 3 (#4392) * is xml transformation is not applied properly, then instead of throwing, we warn * will not show transformation applied successfully message if transformations is not applied * updated patch version of iis on mg task * splitting xml transformation error string into 3 resources * minor changes --- .../Strings/resources.resjson/en-US/resources.resjson | 4 +++- Tasks/AzureRmWebAppDeployment/task.json | 4 +++- Tasks/AzureRmWebAppDeployment/task.loc.json | 4 +++- .../webdeployment-common/fileTransformationsUtility.ts | 9 +++++++-- .../webdeployment-common/xdttransformationutility.ts | 8 ++++++-- .../Strings/resources.resjson/en-US/resources.resjson | 4 +++- Tasks/IISWebAppDeploymentOnMachineGroup/task.json | 6 ++++-- Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json | 4 +++- 8 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson index 5931b7370123..2bc174b31989 100644 --- a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson @@ -143,7 +143,9 @@ "loc.messages.InvalidPollOption": "Invalid polling option provided: %s.", "loc.messages.MissingAppTypeWebConfigParameters": "Attribute '-appType' is missing in the Web.config parameters. Valid values for '-appType' are: 'python_Bottle', 'python_Django', 'python_Flask' and 'node'.
For example, '-appType python_Bottle' (sans-quotes) in case of Python Bottle framework..", "loc.messages.AutoDetectDjangoSettingsFailed": "Unable to detect DJANGO_SETTINGS_MODULE 'settings.py' file path. Ensure that the 'settings.py' file exists or provide the correct path in Web.config parameter input in the following format '-DJANGO_SETTINGS_MODULE .settings'", - "loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following. \n1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. \n2. Ensure that the config file and transformation files are present in the same folder inside the package.", + "loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.", + "loc.messages.FailedToApplyTransformationReason1": "1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. ", + "loc.messages.FailedToApplyTransformationReason2": "2. Ensure that the config file and transformation files are present in the same folder inside the package.", "loc.messages.AutoParameterizationMessage": "ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.", "loc.messages.UnsupportedAppType": "App type '%s' not supported in Web.config generation. Valid values for '-appType' are: 'python_Bottle', 'python_Django', 'python_Flask' and 'node'" } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 7a848c0a4eeb..6a64ca3c9334 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -479,7 +479,9 @@ "InvalidPollOption": "Invalid polling option provided: %s.", "MissingAppTypeWebConfigParameters": "Attribute '-appType' is missing in the Web.config parameters. Valid values for '-appType' are: 'python_Bottle', 'python_Django', 'python_Flask' and 'node'.
For example, '-appType python_Bottle' (sans-quotes) in case of Python Bottle framework..", "AutoDetectDjangoSettingsFailed": "Unable to detect DJANGO_SETTINGS_MODULE 'settings.py' file path. Ensure that the 'settings.py' file exists or provide the correct path in Web.config parameter input in the following format '-DJANGO_SETTINGS_MODULE .settings'", - "FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following. \n1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. \n2. Ensure that the config file and transformation files are present in the same folder inside the package.", + "FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.", + "FailedToApplyTransformationReason1": "1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. ", + "FailedToApplyTransformationReason2": "2. Ensure that the config file and transformation files are present in the same folder inside the package.", "AutoParameterizationMessage": "ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.", "UnsupportedAppType": "App type '%s' not supported in Web.config generation. Valid values for '-appType' are: 'python_Bottle', 'python_Django', 'python_Flask' and 'node'" } diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index 95c07a95130b..8b1ad063d0be 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -480,7 +480,9 @@ "MissingAppTypeWebConfigParameters": "ms-resource:loc.messages.MissingAppTypeWebConfigParameters", "AutoDetectDjangoSettingsFailed": "ms-resource:loc.messages.AutoDetectDjangoSettingsFailed", "FailedToApplyTransformation": "ms-resource:loc.messages.FailedToApplyTransformation", + "FailedToApplyTransformationReason1": "ms-resource:loc.messages.FailedToApplyTransformationReason1", + "FailedToApplyTransformationReason2": "ms-resource:loc.messages.FailedToApplyTransformationReason2", "AutoParameterizationMessage": "ms-resource:loc.messages.AutoParameterizationMessage", "UnsupportedAppType": "ms-resource:loc.messages.UnsupportedAppType" } -} +} \ No newline at end of file diff --git a/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts b/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts index 070d84fa16a2..47c889cdeb2d 100644 --- a/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts +++ b/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts @@ -25,8 +25,13 @@ export function fileTransformations(isFolderBasedDeployment: boolean, JSONFiles: if(environmentName && environmentName != 'Release') { transformConfigs.push(environmentName + ".config"); } - xdtTransformationUtility.basicXdtTransformation(folderPath, transformConfigs); - console.log(tl.loc("XDTTransformationsappliedsuccessfully")); + var isTransformationApplied: boolean = xdtTransformationUtility.basicXdtTransformation(folderPath, transformConfigs); + + if(isTransformationApplied) + { + console.log(tl.loc("XDTTransformationsappliedsuccessfully")); + } + } else { throw new Error(tl.loc("CannotPerformXdtTransformationOnNonWindowsPlatform")); diff --git a/Tasks/Common/webdeployment-common/xdttransformationutility.ts b/Tasks/Common/webdeployment-common/xdttransformationutility.ts index 1f90d8548528..3e13a954460f 100644 --- a/Tasks/Common/webdeployment-common/xdttransformationutility.ts +++ b/Tasks/Common/webdeployment-common/xdttransformationutility.ts @@ -44,7 +44,7 @@ export function applyXdtTransformation(sourceFile, transformFile) { * @param transformConfigs The array of transform config names, ex : ["Release.config", "EnvName.config"] * */ -export function basicXdtTransformation(rootFolder, transformConfigs) { +export function basicXdtTransformation(rootFolder, transformConfigs): boolean { var sourceXmlFiles = expandWildcardPattern(rootFolder, '**/*.config'); var isTransformationApplied = false; Object.keys(sourceXmlFiles).forEach( function(sourceXmlFile) { @@ -59,6 +59,10 @@ export function basicXdtTransformation(rootFolder, transformConfigs) { }); }); if(!isTransformationApplied) { - throw new Error(tl.loc('FailedToApplyTransformation')); + tl.warning(tl.loc('FailedToApplyTransformation')); + tl.warning(tl.loc('FailedToApplyTransformationReason1')); + tl.warning(tl.loc('FailedToApplyTransformationReason2')); } + + return isTransformationApplied; } \ No newline at end of file diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/Strings/resources.resjson/en-US/resources.resjson b/Tasks/IISWebAppDeploymentOnMachineGroup/Strings/resources.resjson/en-US/resources.resjson index 2c55679b997a..810fd392af2a 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/Strings/resources.resjson/en-US/resources.resjson @@ -69,6 +69,8 @@ "loc.messages.EncodeNotSupported": "Detected file encoding of the file %s as %s. Variable substitution is not supported with file encoding %s. Supported encodings are UTF-8 and UTF-16 LE.", "loc.messages.UnknownFileEncodeError": "Unable to detect encoding of the file %s (typeCode: %s). Supported encodings are UTF-8 and UTF-16 LE.", "loc.messages.ShortFileBufferError": "File buffer is too short to detect encoding type : %s", - "loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following. \n1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. \n2. Ensure that the config file and transformation files are present in the same folder inside the package.", + "loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.", + "loc.messages.FailedToApplyTransformationReason1": "1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. ", + "loc.messages.FailedToApplyTransformationReason2": "2. Ensure that the config file and transformation files are present in the same folder inside the package.", "loc.messages.AutoParameterizationMessage": "ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation." } \ No newline at end of file diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/task.json b/Tasks/IISWebAppDeploymentOnMachineGroup/task.json index 73beea42b00c..f2c6f0a740c5 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/task.json +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/task.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 0, - "Patch": 17 + "Patch": 18 }, "demands": [], "minimumAgentVersion": "2.104.1", @@ -176,7 +176,9 @@ "EncodeNotSupported": "Detected file encoding of the file %s as %s. Variable substitution is not supported with file encoding %s. Supported encodings are UTF-8 and UTF-16 LE.", "UnknownFileEncodeError": "Unable to detect encoding of the file %s (typeCode: %s). Supported encodings are UTF-8 and UTF-16 LE.", "ShortFileBufferError": "File buffer is too short to detect encoding type : %s", - "FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following. \n1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. \n2. Ensure that the config file and transformation files are present in the same folder inside the package.", + "FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.", + "FailedToApplyTransformationReason1": "1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. ", + "FailedToApplyTransformationReason2": "2. Ensure that the config file and transformation files are present in the same folder inside the package.", "AutoParameterizationMessage": "ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation." } } \ No newline at end of file diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json b/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json index 7515dbd29ca1..72d759416c7d 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 0, - "Patch": 17 + "Patch": 18 }, "demands": [], "minimumAgentVersion": "2.104.1", @@ -179,6 +179,8 @@ "UnknownFileEncodeError": "ms-resource:loc.messages.UnknownFileEncodeError", "ShortFileBufferError": "ms-resource:loc.messages.ShortFileBufferError", "FailedToApplyTransformation": "ms-resource:loc.messages.FailedToApplyTransformation", + "FailedToApplyTransformationReason1": "ms-resource:loc.messages.FailedToApplyTransformationReason1", + "FailedToApplyTransformationReason2": "ms-resource:loc.messages.FailedToApplyTransformationReason2", "AutoParameterizationMessage": "ms-resource:loc.messages.AutoParameterizationMessage" } } \ No newline at end of file