FieldRefs not working with XML comments
Today I was working on a SharePoint 2010 project where the custom fields and content types where provisioned using a feature. After the feature was activated the custom fields and content types where provisioned in SharePoint, except the content type contained no fields. The element manifest file contained the following xml:
<!-- Base Page --> <ContentType ID="0x010100C568DB52D9D0A1...84E219954237AF3901" Name="Basepage" Description="Basepage" Group="Publishing" Sealed="TRUE" Inherits="TRUE" Version="1"> <FieldRefs> <!-- Originating from MOSS --> <FieldRef ID="{b66e9b50-a28e-469b-b1a0-af0e45486874}" Name="Keywords" /> <!-- Custom fields --> <FieldRef ID="{30607e4e-a3e1-4662-9766-56e1faedb875}" Name="AdminComments" /> </FieldRefs> </ContentType>
The ULS logs showed no errors and I couldn’t figure out what the problem was because the same element manifest file was used in SharePoint 2007. After the stripping the file I figured out that the xml comments were causing the problem. Now my element manifest contains the following:
<ContentType ID="0x010100C568DB52D9D0A1...84E219954237AF3901" Name="Basepage" Description="Basepage" Group="Publishing" Sealed="TRUE" Inherits="TRUE" Version="1"> <FieldRefs> <FieldRef ID="{b66e9b50-a28e-469b-b1a0-af0e45486874}" Name="Keywords" /> <FieldRef ID="{30607e4e-a3e1-4662-9766-56e1faedb875}" Name="AdminComments" /> </FieldRefs> </ContentType>
The content is the same except the comments are missing.

