The default file name given to your solution will match the project name. I.e. a SharePoint project SharePointProject1 will result in a package SharePointProject1.wsp.
If you want VS to spit out a different name, modify the name attribute in the Package\Package.package file for your project.
You may need to restart VS after making this change.
So it’s often the case that I start a project and then decided later I want to refactor such elements like the namespace, package name etc. Let’s start with the namespace.
When you create a new project (lets start with an empty solution), you provide the project name, solution name, and location.
Great. We have our solution. We add a web part item to the project and we get:
Before we go any further, lets build and deploy. Everything looks good according to the web part preview from the web part gallery.
Now we want to change the following:
- Solution Name
- Project Name
- Assembly Name
Renaming the solution, project and files in Solution explorer, and the assembly name through project properties should not cause a problem. But when we change the namespace in the web part code (and update the web part file), we get the following error:
This typically indicates a problem between the web part file, the assembly, and the SafeControl entry in web.config.
If we look at the deployed web part file we see:
If we look at the web.config for the safe control entry:
Notice the SafeControl entry is incorrect for Namespace. In order to correct this, the file SharePointProjectItem.spdata (located in the web part folder in windows explorer) needs to be updated. SharePoint does not update this file for you.
Notice the SafeControl entry above where the namespace value is incorrect. Change this to the correct namespace and re-deploy. Now we’re back in business!