asp.netmsbuildmsdeploywebdeploymicrosoft-web-deploy

MSDeploy setParameter.xml not transforming web.config


In my "myconfig" config profile transform for web.config i have this under appSettings:

<add key="my.config" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" value="derp" />

When I msbuild with this transform the value is transformed correctly. Now I want to build an msdeploy package and transform this value at deploy time.

I drop this parameters.xml in my project root:

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
    <parameter name="my.config" description="sdfsdfsdfsd" defaultValue="fart">
        <parameterEntry kind="XmlFile"
                        scope="\\Web\.config$"
                        match="/configuration/appSettings/add[@my.config]/@value/text()" />
    </parameter>
</parameters>

I build my package

msbuild app.csproj /T:Package /p:Configuration=myconfigprofile;PackageLocation=mydeploy.zip

I look at mydeploy.SetParameters.xml

<?xml version="1.0" encoding="utf-8"?>

<parameters>

  <setParameter name="IIS Web Application Name" value="Default Web Site/myApp_deploy" />
  <setParameter name="my.config" value="fart" />

</parameters>

Then I go into parameters.xml inside of mydeploy.zip and see its there too:

<parameters>
  <parameter name="my.config" description="sdkflsdjfldfj" defaultValue="fart">
    <parameterEntry kind="XmlFile" scope="\\Web\.config$" match="/configuration/appSettings/add[@name='my.config']/@value/text()" />
  </parameter>
</parameters>

looks good so far, then i deploy:

mydeploy.deploy.cmd /Y /M:server1

I look at web.config on the deploy server and the value is not transformed. I see no errors either, how do i debug this even?

When I run msbuild with parameters.xml present what magic happens there? How is the package preps to be able to transform web.config via parameters to web deploy?


Solution

  • This:

    add[@name='my.config']
    

    Had to be changed to this:

    add[@key='my.config']
    

    But the bigger question remains, how do I debug? I had to try a million times and just guess because I had zero errors/logs to help troubleshoot this. Is there verbose logging or some kind of validator or anything at all?

    For debugging technet gave me this to try: msbuild MyProject.proj /t:go /fl /flp:logfile=MyProjectOutput.log;verbosity=diagnostic