Wednesday, February 27, 2013

SPWebConfigModification Research

There's conflicting advise on how to use this feature. My take is not to use clear() and if you go this route, make sure all web.config entries are done using SPWebConfigModification (or else, e.g. if you hand jam entries manually you risk having those changes overwritten).

Note on EnsureSection: at first I thought it was a good idea, but found it only applies to full elements (will not ensure/create e.g. a particular sectionGroup because it requires attributes.

refs:
http://blog.crsw.com/2007/09/20/how-to-modify-the-web-config-file-in-sharepoint-using-spwebconfigmodification/
http://msdn.microsoft.com/en-us/library/ms467128(v=office.12).aspx
http://blogs.devhorizon.com/reza/2008/01/05/spwebconfigmodifications-top-6-issues/
http://msdn.microsoft.com/en-us/library/ff707273(v=office.12).aspx
http://bpetluri.blogspot.com/2010/08/sharepoint-changing-webconfig-for-one.html
http://web.archive.org/web/20081014210148/http://blog.thekid.me.uk/archive/2007/03/20/removing-web-config-entries-from-sharepoint-using-spwebconfigmodification.aspx
http://www.codeproject.com/Articles/45314/SPWebConfigModification-Tool-and-Explorations - shows examples on EnsureSection usage
http://translate.google.com/translate?hl=en&sl=de&u=http://blogs.myfirstsharepoint.de/technikblog/aus-der-praxis-konflikte-zwischen-spwebconfigmodifications-vermeiden&prev=/search%3Fq%3D%2522applicationSettings%2522%2BSPWebConfigModification%26hl%3Den%26biw%3D1172%26bih%3D737&sa=X&ei=8_ssUZPDBO7h0wHWrICADw&ved=0CGcQ7gEwCA - This indicates (and I confirmed through tests) that ensuring a child will not overwrite existing children that don't match.
http://sharepoint.stackexchange.com/questions/306/cant-remove-web-config-entries-with-spwebconfigurationmodification - example
http://oricode.wordpress.com/2008/03/05/spwebconfigmodification-configure-applicationsettings-with-a-feature/ - left comment here

Saturday, February 16, 2013