My release pipeline deploys the application to multiple environments.
Based on the environment, I am trying to set up File Transformations to be executed, though I\'m n
How to apply XML File Transformations on a ClickOnce application through Azure DevOps release pipeline?
File Transform task should work well in your scenario if we can meet its prerequisites:
1.Make sure the transform file(app.Release.config) and the source file({nameOfApplication}.exe.config) are in same path.
2.Make sure your transform file has correct xdt syntax, sample here.
3.Choose latest 2.0-preview
version of File Transform task instead of old 1.0
.
4.Try using valid file name when setting Xml Transformation rules
.(Use {nameOfApplication}.exe.config
instead of *.exe.config
)
In my opinion, #1
and #3
above are always the direct cause of the error Unable to apply transformation for the given package
. Check them carefully!
Some details for above four tips:
1.In project file(xx.csproj) I have this content to make sure the transform file will be copied to output folder. So it will be in same folder with source file xxx.exe.config
.
<Content Include="App.release.config" >
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
2.My test App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="IsPackage" value="false" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
</configuration>
My test App.release.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="IsPackage" value="true" />
</appSettings>
</configuration>
3.Use latest version which fixes some issues:
4.According to some tests, valid name works better than something like *.exe.config
when you already know the application name:
Hope all above helps :)