In SharePoint 2010, there is a nice feature provided by VS 2010 which lets the developer import the WSP into VS 2010 environment where you can select your necessary lists, libraries, reusable workflows and see all these in code view in Visual Studio environment. You can later on deploy this to any site or site collection on your server. Important thing to note that, VS 2010 only allows you to deploy locally which means you cannot deploy anything if your SP server exists elsewhere.
First, let us see how easily you can save a site as a template from the web interface:
Go to site settings of your site. From “Site Actions”, select “Save Site as Template” (Publishing feature needs to be enabled for a site to view this option for a site [not site collection])
Now, Fill up the name of the file which will be saved as. You can select “Include Content” if you want your custom forms and custom reusable workflows to be available in the solution package. If you keep it unselected, it will not save any custom forms or reusable workflows.
Now, after clicking “OK”, you will be redirected to the page where the solution package is saved as template. Click on the file to download and save it.
After saving the WSP file, open your Visual Studio 2010 in “Administrator” mode and follow the steps below:
Choose “Import SharePoint Solution Package” from Installed templates.
Specify your site or site collection URL.
Browse to the location where you saved the “WSP” file.
After clicking on “Next”, you will see all the files available inside that WSP.
Now, you can deselect all and select only the required ones; after click on “Finish” you may get this window which will show a warning about the dependencies. Click “Yes” if required.
After that you will get a message saying “The solution is imported successfully”.
Now, you will be able drill down into all the fields you chose before and see the code for each field in VS. After modifying (if you require so), you will need to click on “Deploy” to deploy the site to your preferred location (which you mentioned while creating the project, you can change the URL from Solution Explorer too).
Once deployed, you will be able to see the elements in your site’s “All Site Content” and the settings for the lists and libraries will be exactly as it was in the other site settings from where you saved the template.