The aim of this project is to offer a utility similar to fxcop but for wsp packages. At the end it should contain enough rules to ensure good practices and allow automated audits or checks at build time for example.
This tool should help :
- developpers; to deliver proper packages that deploys well and that respect some good practices.
- architects/reviewers; to give them an overview of what is the content of a package and report the attention points.
- governance teams and quality teams; to ensure good practices and governance rules to be ensured at build time.
- IT Admins; to give them an overview of what are the components that are required (Publishing/Enterprise/Workflows/Farm Features) and deploy a solution.
Hereby my contribution to their duty ;0)
To use without moderation !
General errors seen before :
- .webpart files reference a class that was refactored or moved.
- overwriting owstimer.exe.config or even web.config !
- features that have conflicting id's.
- resource strings that do not exist.
- content place holders that do not have a capital C... grr
- Libraries defined at site or webapplication level.
- Features using priviledge elevation.
- Features at Site level(contentdb) registring webapplication timer jobs(config db).
- Features that define files that are not part of the package.
- Visible Features that depend on elements of other features without referencing them in their depencies !
- Invalidly structured content types (00 guid 00 guid)
What came up to me is that even big software providers do such things and internet, blogs and even msdn documentation is full of those bad pratices.
I'm not the wholy grail of the best practices neither and every practice is discutable, but when it comes to governance within a team or organization these practices need to be enforced and reported.7
Therefore this tool is fully extandable and customizable to your own needs.
These are sample rules of what is checked by the tool. (2007, 2010 support is comming)
- Do not overwrite sharepoint files : This rule verifies that the WSP's are not overwriting any of the default files provided by sharepoint. This has desastrous consequences when apply'ing service packs or worse when retracting the solution this deletes
the file and does'nt restore any previous versions.
- Do not use PriviledgeElevation in feature receivers : Normally access to the activation screens are only allowed for admin users, therefore you should not need elevation within the feature itself. If you do so the tool will trigger an alert.
- Use resource strings for content types and fields : Checks that the DisplayName and Description attribute are set to use resource strings instead of hard coded strings.
- Do not use spaces in static names : In order to avoid x200 stuff in some names, do not use any space or other illegal chars in the static names of your elements, instead of that use displayname property with a resource string.
- Respect Element scopes : Wihtin sharepoint you cannot bundle items freely at any scope, you need to respect it like; you cannot define site columns on farm level etc.
- Unique Ids : All elements and features within a package should have unique ids.