How to: Create Custom Feature and Package Validation Rules for SharePoint Solutions
You can create custom validation rules to verify the solution package generated by Visual Studio. You can perform full validation on an entire Feature or package by selecting Validate from the context menu of a package or Feature in the PackagingExplorer. Partial validation is performed when you add new SharePonit project items or Features to the project to determine if the Package or Feature would be in a valid state.
To create a custom package validation rule
Create a class library project.
Add references to the following assemblies:
Microsoft.VisualStudio.SharePoint
System.ComponentModel.Composition
Create a class that implements one of the following interfaces:
To create a package validation rule, implement the IPackageValidationRule interface.
To create a Feature validation rule, implement the IFeatureValidationRule interface.
Add the System.ComponentModel.Composition.ExportAttribute to the class. This attribute enables Visual Studio to discover and load your validation rule. Pass the IPackageValidationRule or IFeatureValidationRule type to the attribute constructor.
The following code example demonstrates how to create a custom Feature validation rule.
This example requires references to the following assemblies:
Microsoft.VisualStudio.SharePoint.
System.ComponentModel.Composition.
To deploy the extension, create a Visual Studio extension (VSIX) package for the assembly and any other files that you want to distribute with the extension. For more information, see Deploying Extensions for the SharePoint Tools in Visual Studio.