Update Web.config in Multi-tenant Deployment

I have a Multi-tenant Deployment projects . I have about 150 tenants, each tenant represents an ASP.net site. Each of this ASP.net site has a web.config file with different connection string and other client specific settings. In all of my web.config file I have this line

<compilation debug="true" targetFramework="4.5">

I want to remove debug=“true” from the above tag. I created a NuGet package with a single transform file called Web.Release.config. My transform file looks like this

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)"/>
  </system.web>
</configuration>

I ran this package on all of my 150 tenants, but my default web.config didn’t change , it did not remove debug=“true” from any web.config file. I don’t know what I am doing wrong.

Please help me

Hi,

Thanks for getting in touch! I’m sorry to hear you’re hitting this roadblock! It looks like your syntax is correct, and testing this out seems to remove the debug attribute in my local instance. There’s a very helpful online tool to quickly test out transformations so you don’t have to deploy each time you want to test a change. Do you see the same result using this?
https://webconfigtransformationtester.apphb.com/

If it works as expected on that site, it may come down to the configuration of the step. Would you be willing to provide a copy of your verbose deployment logs with debugging variables enabled? The following doc page outlines how you can produce and export this.

If it still doesn’t work on that transformation tester site, would you be willing to provide a copy of your config files in addition to the log? I’ll be happy to run a test with the exact files. :slight_smile:

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny

Kenny,

Thanks for your reply. It only works if both Web.config and Web.Release.config are in the same NuGet deployment package. My problem is that my NuGet deployment package contains only Web.Release.config . another idea I have is running powershell script to remove debug=“true” from web.config file. But I don’t know powershell , can you please help me write the script . My script will be Post-deployment script and it should be able read all the web.config files of my 150 tenants

Hi,

Thanks for following up! That’s good to hear it works when both are in the same package. Since the web.config file isn’t normally in your package, a PowerShell script could accomplish this if you’re unable to include it in your package going forward. Defining an absolute path to the web.config file isn’t supported unfortunately. If you haven’t seen it yet, you can refer to our advanced configuration transforms examples doc page which outlines what is supported.

Unfortunately I won’t be able to help you write the script itself, but I was able to find a good resource which I think will be really helpful for you. :slight_smile:
https://blogs.msdn.microsoft.com/sonam_rastogi_blogs/2014/08/18/update-configuration-files-using-powershell/

I hope this helps! Don’t hesitate to reach out if you have any further questions going forward.

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.