Missing feature for custom action in Visual Studio

Missing feature for custom action in Visual Studio

Building your Apps for SharePoint will most likely be something you will do with Visual Studio 2013. And depending on the requirements you will use either the Provider-hosted or SharePoint-Hosted template that is available. If you are working with the Provider-hosted template you will get two visual studio projects that you can use to deploy your artifacts for your app. The App project will contain all SharePoint related artifacts, while the web project contains the web related artifacts.

If you examine the App project a little closers you will see it contains two files by default:

  • AppIcon.png
  • AppManifest.xml

If you compare this to a default SharePoint-hosted app that will only contain an App project you are missing quite a few files. One of the important files that you are missing by default is the feature that is responsible to deploy all the artifacts. This can be easily explained by the fact that there are no artifacts to deploy yet. However it is slightly confusing the first time you look at it. If you would add an artifact to the project you are most likely to see a new folder for features, and a new folder for the package appear. This will take care of deploying the artifacts as you would expect, resulting in the following view

Visual Studio App Project contents with custom action and feature

However there is an exception to the workings of Visual Studio. If you would add a Menu Item Custom Action or a Ribbon Custom Action, the artifact will be created in the project, but it will not generate a Feature and a Package. So even though the Ribbon Action (or Menu Item) artifact is available in the project it will not be deployed. 

Visual Studio Project setup with Ribbon Custom Action

This will result in slight unexpected behavior, as the artifact is available there is no package to deploy it, nor a feature to activate it. In order to fix this problem you can easily create an empty element or module, as this will trigger the creation of a feature and a package. Once the feature and package are available you can just delete the element or module that you created as it is no longer needed. It is unclear why by default the feature is not created when creating these type of artifacts, however the work arround is pretty easy.

By default the Ribbon Custom Action and the Menu Item Custom Action are not added to the default feature, though it would be a good practice to do so, so after deleting the empty element just add the Custom Acton to the feature definition.

Leave a Reply