azure-pipelines-tasks: FileTransform correctly applies all transforms but still reports Error Unable to apply transformation for the given package - Changes are already present in the package.
Required Information
Question, Bug, or Feature?
Type: bug
Enter Task Name: FileTransform
Environment
-
Server - Azure Pipelines or TFS on-premises?
- If using Azure Pipelines, provide the account name, team project name, build definition name/build number:
- Account: PromontoryNetwork
- TeamProject: newco.com
- Definition: 2
- Build Number: 0.2.18
- If using Azure Pipelines, provide the account name, team project name, build definition name/build number:
-
Agent - Hosted or Private:
- If using Hosted agent, provide agent queue name: windows-latest
Issue Description
I have a multi-stage YAML pipeline, that has the following Filesystem Transform task defined in a Deployment Job:
- task: FileTransform@2
displayName: 'Apply Release Transforms'
inputs:
folderPath: '$(System.DefaultWorkingDirectory)\$(artifactName)\deploy\'
enableXmlTransform: true
xmlTransformationRules: |
-transform *.Release.config -xml *.config
-transform *.$(Environment.Name).config -xml *.config
-transform config\**\*.Release.config -xml config\**\*.config
-transform config\**\*.$(Environment.Name).config -xml config\**\*.config
xmlTargetFiles: |
web.config
We have two configuration files in the root of the application that need at least the Release transform applied (web.config and ApplicationInsights.config) as well as optional environment transforms. Similarly there are a number of .config files in the config folder, that have optional release and environment transforms.
Looking at the logs and the transformed files, all transforms are being correctly applied to the target files, but we are still getting the following error reported from the task (note that this is not stopping the deployment, but it is creating noise in the reports that makes it look like an error has occurred):
##[error]Unable to apply transformation for the given package - Changes are already present in the package.
Task logs
Troubleshooting
Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting
Error logs
##[error]Unable to apply transformation for the given package - Changes are already present in the package.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (2 by maintainers)
For anyone landing here who wants to squelch this error when doing JSON-only transforms:
There are some other requirements which made us to add this change. https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/FileTransformV2
If you don’t want to fail task, you can check “Continue On Error” checkbox.
This is as per design https://github.com/microsoft/azure-pipelines-tasks/issues/12277
Just to follow up with an example:
I would respectfully suggest then that the design is wrong.
There are no meaningful errors in the tasks, and they are successfully applying the transforms and replacements, but the tasks are erroneously reporting an error back to the pipeline and showing as errors on the report when in fact everything is behaving as expected.
How is this “by design”?
This is a terrible suggestion. I do want the pipeline to stop on errors.
That should not be an error in the first place. I would suggest fixing the root cause instead of suggesting us brittle workarounds.
Like many others, I stumbled upon this issue while building a YAML pipeline and needed to transform an appsettings.json. @shemsiu 's suggestion worked, but like many others, I think requiring a blank XML transform makes little sense when you only want to do a JSON transform.
I agree that this is very unhelpful. We have created a Task Group to run the same steps in all environments, including variable substitution in JSON and XML. In our production environment there is no variable substitution as the application is deployed with a prod override json config file with no need to replace any variables. In lower regions there is a test override json config file but we also substitute 3 or 4 configs depending on the test environment. I upgraded to V2 of this task as it did JSON and XML in one hit, instead of 2 v1 tasks and the behaviour changed and broke when deploying to production.
In my eyes this is a regression from V1 and prevents good CI practices of using the same steps in all regions with differences via variables etc.
This is so broken.
Why should I have to enter an empty xmltTransformationRules property just to suppress an error when I only specified jsonTargetFiles?
Or use continue on fail? That will suppress actual failures…
Somtimes I get astonished/disappointed about the level of code/functionality that comes from Microsoft. I would have never let this task pass QC.
I ran into this issue while using Classic Pipelines. It seems to me that this happens when there are no variable substitutions to be made.
I was in the process of creating a new stage and all existing variables were scoped specifically to other (existing) stages. As soon as I added a valid variable to the new stage’s scope the problem went away.
It does seems useful to be notified when no transformations take place, as it highlights that some configuration might be missing. But for this to cause the task to trigger an error seems overkill and counterproductive. A warning seems like it would be more helpful.