Error in Visual Studio : No VisualStudio Registration Attribute found in this assembly

This error happens when you create a project of type “Visual studio package” (or any Extensibility project) from Visual Studio 2010 and then you remove the file Package.cs from the project for some reason. TO fix please open the project file manually and remove the entry.

1. <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets" />
2. Or, Add the RegistrationAttribute to the class that inherits the Microsoft.VisualStudio.Shell.Package class.

Or delete this entry in the project file <GeneratePkgDefFile>false&lt/GeneratePkgDefFile>

If you are interested in knowing the reason behind this, please read further. When you create a “Visual Studio package” project (or any Extensibility project) from Visual Studio,  it automatically adds a RegistrationAttribute to the class that extends from the Package class. This is done in order to create .pkgdef file automatically from these attributes. The pkgdef file contains the list of registry entries that are needed by Visual Studio to load this package during runtime. This is the first part.

The second part is why MSBuild throws error during compilation ?

One of the first steps MSBuild does to build a Visual Studio extensibility project is to run the task CreatePkgDef that resides in the file Microsoft.VsSDK.targets. This task reflects the assembly in context and looks for a Class that is decorated with RegistrationAttribute. In our case we have deleted the file that has this attribute, but the project file (.csproj for example) still includes the Microsoft.VsSDK.targets file, which tries to look for this attrribute.

Am not sure if this is a bug, but this is more of a ease of use story. Smile

soundararajan