Search code examples
msdeploywebdeploy

Transforming files with msdeploy


Can I use the config transforms mechanism of MSDeploy to transform other files?


Solution

  • (another approach)

    The msdeploy packaging is jsut invoked during an MSbuild run for your project.

    TransformXml is an included task of a .csproj or .vsproj build.

    Just modify your build process to invoke that task on whatever file you need.

    For example, what we do is write a custom target

    <Target Name="TransformFile">
    
        <TransformXml Source="$(DestinationPath)\$(Sourcefile)" 
           Transform="$(DestinationPath)\$(TransformFile)" 
           Destination="$(DestinationPath)\$(DestFile)" />
        </Target>
    

    Then modify your .csproj to run this BEFORE the Publish task is invoked.

    <CallTarget Targets="TransformFile" 
       Condition="'$(CustomTransforms)'=='true'" />