3

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?

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

1

If you are using MSDeploy you can get the full output of the deployment by using the following:

msdeploy -verb:sync -source:dirpath=C:\WebDeployDemo\Src -dest:dirpath=C:\WebDeployDemo\Dst -setParamFile=C:\WebDeployDemo\ParameterFile.xml -verbose >msdeploysync-verbose.log

This helps with VSTS WebRM deployment debugging if you use the -verbose flag.

Sources: https://learn.microsoft.com/en-us/iis/publish/troubleshooting-web-deploy/troubleshooting-web-deploy https://blogs.msdn.microsoft.com/spike/2012/10/12/using-msdeploy-to-update-and-remove-sections-in-web-config-a-simple-example/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.