azure-pipelines-release-pipelineweb-config-transformmagic-chunks

Is it possible to use the web.config transformations for app.config files within a VSTS release template?


I'm aware that you can use web.config transformations as part of the build for app.config files, but in my case, I'm trying to do this for a little scheduled task that gets deployed to an on-premise server for multiple environments.

I'd rather not have to create multiple build configurations given the only change is the app.config, so I'm trying to use the Magic Chunks extension, but due to the size of the changes I want to make, I'm having to use a json file (rather than using inline json).

When I look at the release logs, the Magic Chunks step is failing with:

2018-01-10T17:33:27.6366230Z ##[section]Starting: Config transform - \\tfs-build\Tasks\DevAzureDeliveryDaemonTest\AzureDispatchers.xml
2018-01-10T17:33:27.6366230Z ==============================================================================
2018-01-10T17:33:27.6366230Z Task         : Config transformation
2018-01-10T17:33:27.6366230Z Description  : Transform config file with Magic Chunks
2018-01-10T17:33:27.6366230Z Version      : 2.0.3
2018-01-10T17:33:27.6366230Z Author       : Sergey Zwezdin
2018-01-10T17:33:27.6366230Z Help         : [More Information](https://github.com/sergeyzwezdin/magic-chunks)
2018-01-10T17:33:27.6366230Z ==============================================================================
2018-01-10T17:33:27.6522335Z Preparing task execution handler.
2018-01-10T17:33:27.8710415Z Executing the powershell script: C:\agent\_work\_tasks\MagicChunks_985284e0-a7d2-4e4d-802c-0a516bffaadf\2.0.3\transform.ps1
2018-01-10T17:33:28.4335027Z ##[error]System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2018-01-10T17:33:28.4335027Z    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
2018-01-10T17:33:28.4335027Z    at System.Reflection.Assembly.GetTypes()
2018-01-10T17:33:28.4335027Z    at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
2018-01-10T17:33:28.4335027Z    at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
2018-01-10T17:33:28.4335027Z    at System.Management.Automation.CommandProcessorBase.Complete()
2018-01-10T17:33:28.4960072Z Transformation found: dispatcher[@Name='oldvalue']/@Name: newvalue

(The other transformations defined in the json file are found here, but redacted for brevity)

2018-01-10T17:33:28.4960072Z 
2018-01-10T17:33:28.4960072Z 
2018-01-10T17:33:28.5741199Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified." ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2018-01-10T17:33:28.5741199Z    at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
2018-01-10T17:33:28.5741199Z    at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
2018-01-10T17:33:28.5741199Z    --- End of inner exception stack trace ---
2018-01-10T17:33:28.5741199Z    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2018-01-10T17:33:28.5741199Z    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z ##[error]PowerShell script completed with 2 errors.
2018-01-10T17:33:28.5897571Z ##[section]Finishing: Config transform - \\tfs-build\Tasks\DevAzureDeliveryDaemonTest\AzureDispatchers.xml

Has anyone seen this before, and know how to resolve (or know of a better way to achieve this)?


Solution

  • This appears to be an issue with version 2.x of the Magic Chunks Task. Until that is resolved, changing the release to use version 1.x of the task allows to complete