是否可以在 VSTS 发布模板中对 app.config 文件使用 web.config 转换?

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

我知道您可以使用 web.config transformations as part of the build for app.config files,但在我的例子中,我正在尝试为一个小的计划任务执行此操作,该任务将部署到多个环境的本地服务器。

鉴于唯一的变化是 app.config,我宁愿不必创建多个构建配置,所以我正在尝试使用 Magic Chunks 扩展,但由于我想要的变化的大小要制作,我必须使用 json 文件(而不是使用内联 json)。

当我查看发布日志时,Magic Chunks 步骤失败并显示:

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.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

(json 文件中定义的其他转换可在此处找到,但为简洁起见进行了编辑)

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

有没有人以前见过这个,并且知道如何解决(或知道实现这个的更好方法)?

这似乎是 an issue with version 2.x of the Magic Chunks Task。在解决该问题之前,将版本更改为使用任务的版本 1.x 允许完成