6

We are setting up a new Helix based system, and are looking at making the development process as easy as possibly from a devOps point of view, I seem to have a disconnect however in assembly versions after the deploy.

For example we have updated a few packages to the latest version, Newtonsoft for example is now version 10.0.0 however the generic Sitecore install has binding mappings up to version 6.0.0.

Has anyone got a good way of collecting those binding mappings from the projects and having them deployed out into the Website root web.config?

The example that I'm talking for example about would be automatically changing the below:

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>

and updating it to the below based on an amalgamation I guess of all of the web config's from the different feature, foundation and project projects.

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>

Any insight welcome.

Thanks!

  • I have a web.config in a base multisite website project in the Project level. It is the only web.config that is deployed in my entire solution. I update all my dependent assemblies and transforms in there. – Chris Auer May 16 '17 at 12:31
4

If you take a look at the habitat demo - you will see that they use web.config.transform files. This is an example file from the Project/Common website project:

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

<configuration  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.codedom xdt:Transform="InsertIfMissing">
    <compilers xdt:Transform="InsertIfMissing">
      <compiler xdt:Transform="InsertIfMissing" xdt:Locator="Match(language)" language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler xdt:Transform="InsertIfMissing" xdt:Locator="Match(language)" language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>

As you can see, they are standard .config transform files using xdt. They get applied to the web.config file deployed to your solution using a gulp task:

04-Apply-Xml-Transform uses msbuild to apply those transform files and update the web.config file in the website root folder defined in gulp-config.js

You do have to be careful with your xdt transforms with this method tho - you will notice that the example uses InsertIfMissing over a straight Insert - this is because once the transform has been applied to the target file, it is there for all future transforms. So you could get things added multiple times if you do your transforms without checking that.

  • Thanks for the responses and the warning Richard. Got it working now. Perfect. – Henry Tait May 17 '17 at 13:02

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.