How to change a SharePoint feature name in Visual Studio 2010

Relates to: Visual Studio 2010

The Situation

Unlike in Visual Studio 2007,  when you use Visual Studio 2010 to create a SharePoint feature and then deploy the solution, you’ll notice that the default feature name is in the format: ProjectName_FeatureName. I want to change this feature name so that it follows my own naming convention.

Get Started by Creating a Feature in Visual Studio 2010

Once you create a new project in Visual Studio 2010 based on a SharePoint template, you can add a feature to the project by right-clicking on the “Features” folder in the “Solution Explorer” view and then clicking “Add Feature”. In my example below, I created a new feature called Feature1:

Add Feature

Deploy the Solution

Deploy the solution by right-clicking on the solution and then clicking “Deploy”.  You’ll notice in the “Features” folder in the 14 hive that the feature follows the  format: ProjectName_FeatureName:

Deploying Solution

Change the Feature Name

To change this name, double-click on the feature in the “Solution Explorer” view to display the feature properties. Under properties, you’ll see the feature’s “Deployment Path” property, which by default is set to:

$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$

The first token is the project name and the second token is the feature name. Change the feature so that the name is only set to the feature name by setting the “Deployment Path” to:

$SharePoint.Feature.FileNameWithoutExtension$

When you deploy the solution again, you’ll see that the feature in “Features” folder will actually match the feature name in the project:

feature Folder

Conclusion

In Visual Studio 2010, you can change the default SharePoint feature name by setting the feature’s “Deployment Path” property to only the feature name token.