microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

[BUG]: FileTransform@V2 prints error, but replaces strings #20286

Open eddynaka opened 1 month ago

eddynaka commented 1 month ago

New issue checklist

Task name

FileTransform

Task version

2.244.1

Issue Description

I use file transform to update some settings in my appSettings.json file with the following snippet:

- task: FileTransform@2
  displayName: 'Update host.json with production configuration for GitHubProcessor'
  inputs:
    folderPath: '$(System.DefaultWorkingDirectory)/SOME_PATH/Publish/'
    jsonTargetFiles: host.json

When the pipeline executes, I can see the following:

Starting: Update host.json with production configuration for GitHubProcessor
==============================================================================
Task         : File transform
Description  : Replace tokens with variable values in XML or JSON configuration files
Version      : 2.244.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/file-transform
==============================================================================
##[error]Unable to apply transformation for the given package - Changes are already present in the package.
Applying JSON variable substitution for host.json
Applying JSON variable substitution for D:\a\_work\1\s\SOME_PATH/Publish\host.json
Substituting value on key keyVaultEndpoint with (string) value: SOMETHING
Substituting value on key RedisCacheHostName with (string) value: SOMETHING
JSON variable substitution applied successfully.
Finishing: Update host.json with production configuration for XXX

As you can see, it works, but is also shows an error:

##[error]Unable to apply transformation for the given package - Changes are already present in the package.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

windows-latest

Relevant log output

##[error]Unable to apply transformation for the given package - Changes are already present in the package.

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

No response

Deekshitha981 commented 2 weeks ago

Hi, we are actively working on this issue. Will provide the updates asap.

EshitaD commented 1 day ago

Hi @eddynaka, can you please the share me the repro steps?

eddynaka commented 1 day ago
  1. Create a build pipeline that has a json file with properties, let's say KeyA = ValueA, KeyB = ValueB
  2. Add a task to transform KeyA value to ValueAA and KeyB value to ValueBB
  3. Upload as artifact so you can validate the transformation
  4. Run

If you run the steps above, you will see that the artifacts will have the modified json file as expected, but you will also see errors in your pipeline regarding the replacement.