XDT transform - attributes in root node problem

Topics: General
Sep 4, 2013 at 1:59 PM
So I have this config file that I want to transform using an XDT file during install.
It's located in my project in config/ClientDependency.config
<?xml version="1.0" encoding="utf-8"?>

<clientDependency version="2" fileDependencyExtensions=".js,.css">
  <!-- config stuff here -->
My config/ClientDependency.config.install.xdt looks like this:
<?xml version="1.0"?>

<clientDependency xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <test xdt:Transform="InsertIfMissing" />
And the expected output would be (as tested on https://webconfigtransformationtester.apphb.com/):
<?xml version="1.0" encoding="utf-8"?>

<clientDependency version="2" fileDependencyExtensions=".js,.css"> 
  <!-- config stuff here -->
<test /></clientDependency>
However, when I run Update-Package CDConfigTransformTest (a tiny local test package) I get a generic error:
An error occurred while applying transformation to 'config\ClientDependency.config' in project 'MvcApplication8': Object reference not set to an instance of an object.
When I then open up the existing config\ClientDependency.config file it is suddenly completely empty.

HOWEVER. If there are no attributes on the root XML element ("clientDependency") then this XDT file works as expected, no problem:
<?xml version="1.0" encoding="utf-8"?>

  <!-- config stuff here -->
Two questions:
  1. I don't understand why this is a problem in NuGet and not for ctt.exe nor the online web config transform tester.
  2. I've spent the better part of a day on figuring out why my package install failed, only when distilling it down to the package doing ONE thing (the transform) in a completely empty project I narrowed down the problem. Only because a different config transform worked I noticed that the only difference was the root XML element. How would I have been better able to debug this, I wish I had gotten a stack trace or ANYTHING other than a generic "object reference not set".
Sep 14, 2013 at 1:00 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 14, 2013 at 1:04 AM
Thanks for reporting. This is a bug. We'll fix it in the next release.
Sep 14, 2013 at 1:22 AM
Upon investigation, I found that if the <clientDependecy> element has only one attribute, it works; but as soon as I add another attribute, no matter what it is, then the exception occurs.