If we have to audit a SharePoint environment in terms of the artifacts deployed or we are working for a customer demanding high quality in our development process, it is a good practice to do an exhaustive analysis of the artifacts already deployed or planned to be deployed in order to detect/prevent any issue or problem caused by those artifacts. One of the possibilities for doing that analysis is to use Microsoft SharePoint Online Code Analysis Framework (MSOCAF) provided by Microsoft and available through the following link: https://caf.sharepoint.microsoftonline.com/. You can freely use MSOCAF for analyzing SharePoint solutions and detect any problems introduced by them in a SharePoint farm. In this blog post I will do a first approach about how to use MSOCAF for analyzing SharePoint Solutions.
Installing MSOCAF in a CloudShare SharePoint development environment
First step in order to start using MSOCAF is to download and install the tool in your SharePoint development environment:
- Open your Internet browser and navigate to the MSOCAF Url. On the page footer, click the MSOCAF link version you want to use. In my case, I’m going to install MOSOCA for SharePoint 2010.
- In the next page, you can see the minimum requirements you need (SharePoint 2010 + .NET Framework 3.5 SP1 in this case) in order to use MSOCAF and also the related End User License Agreement. Once you accept the License Agreement, you are ready to install MSOCAF by means of the “Install” button.
- Once you the installation process begins, you will be prompted to install additional components like MSOCAF Event Source and Enterprise Library 41. Just install them.
- When installation process ends, the MSOCF main window is displayed. As you can see, you can start the analysis of your SharePoint solutions by using the Analyze option. Additionally, you can test a deployment of your SharePoint solutions in the local environment, do a rollback or submit the artifacts to Microsoft just in case you are creating these components for SharePoint Online.
- Next MSOCAF window informs about the required folder structure in order to perform a SharePoint solutions analysis using the tool. As you can see, it is mandatory to define such folders and you have to use the same name. Otherwise, you will not be able to start a solutions analysis.
- Once you have created the folder structure, click the “Next” button so next MSOCAF window is shown. This new window contains information about the set of rules that are going to be applied when doing the Analysis. As you can see, the set of rules used by MSOCAF is quite complete.
- Next window allows you to specify the path where you have defined the folder structure required by MSOCAF. Once you have added this path, you can start the MSOCA analysis by clicking the “Analyze” button.
- In the analysis process, you can be prompted by early errors found by MSOCAF due to problems in the folder structure defined or because the folders are empty. Just cancel the analysis, fix the problems and start again.
- Once everything is fine in terms of folder structure and contents inside the folders, the real analysis starts. For instance, in my case I have analyzed a really dummy SharePoint Solution and as a result, I have obtained a report with the errors and warnings generated by MSOCA. As you will see, this report is really interested for two main reasons:
- First one, you will have a list of problems or issues that need to be fixed in order to guarantee a safe deployment of your SharePoint solutions. Note that some of the errors dropped by MSOCAF are not necessarily applicable to a SharePoint On-Premise deployment since the tool was designed for SharePoint Online.
- Second one, you can learn a lot with the MSOCAF analysis since the report will inform you about best practices you should follow when creating SharePoint Solutions: do a good exception handling, use SharePoint Object Model in a right way, etc.
And that’s all in this first article about how to use MSOCAF to analyze SharePoint Solutions. Happy CloudSharing!