1

I am little new to sitecore and I got a work thats bugging me. I was given a task to applying sitecore patches to the project and deploy to Dev. There were 3 patches. I completed the first two as it was to applied in Sitecore.config file. The third patch was to add config in "appSettings" node and "assemblyBinding" node in Web.config file. When I used the traditional way of patching like I used for the first two, I was getting an error and later I found out this: enter image description here

My project doesn't use slowcheetah. I researched more about this and found that I have to do web config transforms. The more I researched how to do transforms more confused I got. Below are the config that I have to insert in Web.config :

Under appSetting node : <add key="Telerik.AsyncUpload.ConfigurationEncryptionKey" value="YOUR_ENCRYPTION_KEY_HERE" />

Under assemblyBinding node :

      <dependentAssembly>
        <assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" />
        <bindingRedirect oldVersion="2015.1.401.45" newVersion="2017.2.621.45" />  
      </dependentAssembly> 

I was hoping to get a simple solution or references to articles on how to do insert these configs in web.config file.

3
1

Please see if below links and snippet helps:

  1. Build Configuration file for transformation: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/transform-webconfig?view=aspnetcore-3.1#build-configuration

You would have to first add transform web config or use default debug/release transformation file provided for Web.Config in solution.

  1. Basics and Examples for transformation: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic#xml-transformation-example

You can try below for App settings and similarly for bindings as shared by Jose.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
 <add key="Telerik.AsyncUpload.ConfigurationEncryptionKey" value="YOUR_ENCRYPTION_KEY_HERE" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
</appSettings>
</configuration>
1

The patching system used by Sitecore, and the config transform system used by ASPNet more broadly, are quite different animals.

Firstly, in Sitecore (as you already noticed) you ship the original file and all the patch files to the target runtime environment as content. Which patch is applied can be controlled using special Sitecore-specific attributes in the XML content.

So far, so good.

Config Transformations (or XDT transforms, colloquially) are are applied at publish time, or in some circumstances, during the execution of a Release Pipeline. Traditionally, XDT transforms allow you to specify rules that apply to web.config (only) and then vary them by build configuration, i.e. Debug and Release - that's the origin of the transform file names web.Debug.config and web.Release.config. SlowCheetah is a plugin to the msbuild system that allows this sort of transform system to be used with any XML file, not just web.config, which means you can make these files apply to Sitecore configs as well, though I can't think of a good reason to do that. Even with SlowCheetah, the transform is applied at publish time (or in a release pipeline under some conditions).

Because these are applied at publish or release time, you can't just ship these files along with your web app and expect them to be applied - they don't work that way.

If you need to alter AppSettings you have a couple of options, depending on your deployment model:

  1. Create XDT files similar to @Vaishali's example and add them to your source control - these will apply to your local Dev environment, generally in Debug config and to your production environment, generally in Release config
  2. Use features of your Release Pipeline tools to set AppSettings during delivery based on (secure) variables - in Azure Dev Ops this is a common approach
  3. If you are using Azure Web Apps, you can leave the settings as-is and set the values in the Azure portal against the Web App directly, as these values will supersede the files anyway

We will need to know more about your deployment process to help with the XDT setup any further.

I suggest reading the linked articles by @Vishali as these will give you a better understanding of the XDT system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.