I posted about an issue I had been facing with deploying document sets via XML, where things like the custom welcome page and the shared fields (defined in XmlDocuments) wasn’t showing up.
Here’s a further issue I encountered. I defined my Document Set content type in the usual way. A bunch of Site Fields, then the Content Type definition, and then within the FieldRefs section some FieldRef elements for the fields to use.
At some point, I started to experience a strange error – when I was deploying the solution, I would get an error:
Error occurred in deployment step ‘Activate Features’: Invalid field name.
After a bit of research, things pointed to the fact that this error was caused by not declaring a Name attribute in the FieldRef. And adding a Name in to the FieldRef resolved the problem. However, I had another solution, doing the same thing, which would deploy successfully, but didn’t specify the Name attribute!
After some trial and error, I narrowed it down to the Overwrite attribute of the content type declaration. According to MSDN:
Optional Boolean. TRUE to overwrite an existing content type with the same ID.
The default is FALSE.
I’d set this to true, for obvious reasons. If you remove the attribute, then FieldRef with no Name attribute deploy successfully. And the existing content type is overwritten as well!
Yet another bug/feature/futureproof attribute (like Version, it seems) that displays inconsistent behaviour and can cause lots of issues! Well worth getting used to the ContentType and Field schemas, and I’d suggest using the bare minimum of attributes required.