6

My manager told me: "We don't create a WSP package for an entire existing SharePoint site, we just need to package master pages, CSS, images and page layout files into a solution package." Is it possible to create something like this?

1
  • You keep asking the same question - I am merging this with the latest one. Please don't ask the same or similar question again. [moderator]
    – SPDoctor
    Mar 17, 2013 at 14:14

5 Answers 5

11

Ok, for the wsp part follow laurie, or if your lazy add wspbuilder to visual studios to build the wsp for you.

now to add the masterpage and css:

create an empty project

create an empty project

add module

add module

styles adding

as you can see above, remove the sample.txt, right click styles and add your masterpage and add another module for css :)

for the css, click on the elements.xml and add the following:

Url = “Styles Library” and file Type = GhostableInLibrary

<Module Name="Styles" Url="style Library">
<File Path="Styles\newstyle.css" Url="newstyle.css" Type="GhostableInLibrary"/>
</Module>

the first part Styles\newstyle.css is the module name and then the file name, the url is the location you want it in. The module url is the location you want to add this to.

for masterpage:

<Module Name="Module" List="116" Url="_catalogs/masterpage">
<File Path="Module\Sample.master" Url="Module/Sample.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="false" />
</Module>

same as the css the masterpage is the same, Module\Sample.master module is the module name and the sample.master is the file name within the module within your project. the module url is saying to put the file within the catalogs area.

for images and for page layout files can be done exactly the same way!

reference:

masterpage: http://www.c-sharpcorner.com/uploadfile/anavijai/creating-a-custom-master-page-in-sharepoint-2010-using-visual-studio-2010/

CSS: http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2009/11/23/how-to-deploy-a-style-sheet-into-content-library-using-visual-studio-2010-beta-2.aspx

page layouts: http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=71

http://blogs.msdn.com/b/kaevans/archive/2011/04/02/code-behind-page-layouts-with-visual-studio-2010.aspx

image:

add image to the module folder, your elements file will look like this:

<Module Name="Previews Images" Url="_catalogs/masterpage/$Resources:core,Culture;/Preview Images">
  <File Path="Preview Images\image.png" Url="image.png" Type="GhostableInLibrary">
      <Property Name="Title" Value="Custom Preview Image" />
  </File>
</Module>

or instead of module just create the directory within your project 14/template/images add the image files within this folder will add them to 14hive image folder.

http://msdn.microsoft.com/en-us/library/ee231567.aspx

as i said above you can do laurie's way or.... use ms build:

  1. On the Windows Start menu, choose All Programs, Accessories, Command Prompt.

  2. Change to the directory where your SharePoint project is located.

  3. Enter the following command to create a package for the project. Replace ProjectFileName with the name of the project.

msbuild /t:Package ProjectFileName

example, you could run one of the following commands to package a SharePoint project called ListDefinition1.

msbuild /t:Package ListDefinition1.vbproj
msbuild /t:Package ListDefinition1.csproj

http://msdn.microsoft.com/en-gb/library/ee231588.aspx

or you can use wspBuilder (which i use), download it, install it to Visual studios and right click your project.. select wsp build, select build wsp. The wsp will be added to the project for you. If you goto the directory where you can see the project files youll see the wsp there aswell.

build project using vs2010

http://wspbuilder.codeplex.com/downloads/get/94507?releaseId=30858&ProjectName=wspbuilder

before build:

before build

build (ignore the cmd as your using vs2010 build not cmd)

build

after build

after build

I hope this answers all your questions! Iv tried to make it as simple as possible! your tasks should be very simple... once you have done one module the rest is very simple todo and easy to understand :) , wspbuilder is easy to use and fast for creating as you dont need to do any manifest as it does it for you!

3
  • Is there a version of WSPBuilder for Sharepoint 2013 with Visual Studio 2013?
    – djmsmith
    May 14, 2014 at 13:58
  • 1
    no there isnt as 2013 uses .net 4.5 whereas the last release was for 2010 .net 3.5! for 2013 you should be able to remotely deploy to the server! You create your project as you would within VS but this time you add in the deployment url, once finished you can build the project and then click deploy. It will deploy either local or remote! msdn.microsoft.com/en-us/library/hh370987.aspx if remote it will ask for login details!
    – Ali Jafer
    May 14, 2014 at 14:38
  • 1
    also look here for more detail why they havent followed through to 2013 stackoverflow.com/questions/16144289/wspbuilder-for-vs-2012
    – Ali Jafer
    May 14, 2014 at 14:51
17

With Visual Studio 2010 it is easy to build a WSP. Additional tools are not required, especially for a project as you described. The basic steps are:

  1. Create a new SharePoint 2010 project using the Empty SharePoint Project template.
  2. For each of your items that you want to add, right click on your project in Solution Explorer and choose Add New Item.
  3. Choose the item type (Visual Webpart, etc.) and VS2010 will stub out your files. An element manifest is automatically created for you and it is automatically added to a feature.
  4. When you are ready to create your package, you can use VS2010. Right click on your project in Solution Explorer and choose Package or Deploy (which will package and deploy to whatever site you have specified in your project properties).

Here is a Visual How-To to get you started.

2
  • Thanks buddy. it is too useful for me. one more question i need to add here ... How to create picture library list definition in visual studio 2010 environment ?
    – Red Swan
    Jun 18, 2011 at 6:13
  • Here is a link which shows how to create a list definition in VS2010: msdn.microsoft.com/en-us/library/gg276355.aspx. However, if you only need a picture library, instead of a new list definition, you can just create a List Instance. In Solution Explorer, right-click your project, choose Add New Item > List Instance. A wizard will start where you can choose Picture Library as the list to instantiate.
    – Laurie
    Jun 18, 2011 at 20:59
2

in visual studios 2010:

With Visual Studio 2010 it is much easier to build a wsp. Additional tools are not required, especially for a project as you described. The basic steps are:

1.Create a new SharePoint 2010 project using the Empty SharePoint Project template.

2.For each of your items that you want to add, right click on your project in Solution Explorer and choose Add New Item.

3.Choose the item type (Visual Webpart, etc.) and VS2010 will stub out your files. An element manifest is automatically created for you and it is automatically added to a feature.

4.When you are ready to create your package, you can use VS2010. Right click on your project in Solution Explorer and choose Package or Deploy (which will package and deploy to whatever site you have specified in your project properties).

http://msdn.microsoft.com/en-us/library/gg131919.aspx

above was taken from:

How to create the wsp package in visual studio 2010 with following features?

For SPD it packages workflows in wsp format but anything else your out of luck! reason being that you need to have a feature or other to deploy the files and cant just be in a wsp file. So back to 2010 you would need to go to make the feature and package the files! so best to stick with vs2010 as it does most of the work for you compared to vs2007 which is far harder compared to 2010.

for vs2012 as you require follow this doc: (still simple to make wsp/features ;) for your requirements)

http://msdn.microsoft.com/en-gb/library/ee231560.aspx

2
  • when I try to create a sharepoint project, it says that there is no sharepoint server in my website.
    – Gravity M
    Mar 13, 2013 at 15:37
  • in SPD or vs2012?
    – Ali Jafer
    Mar 14, 2013 at 8:59
1

See if this works for you

Export the Sharepoint Site into a wsp file Import wsp file into a Visual Studio project

I have not tried this check this msdn link

1
  • @Thomspon this works well.
    – Gravity M
    Mar 14, 2013 at 13:21
-1

Have you tried "Site Settings->Site Actions->Save Site as Template"? It doesn't create a WSP but it create a .STP file that allow you to recreate the site with all its contents.

http://office.microsoft.com/en-001/sharepoint-server-help/save-a-site-as-a-site-template-HA010157779.aspx

2
  • Saving a site as a template does not include sub-sites and the other frills mentioned.
    – teylyn
    Mar 14, 2013 at 9:41
  • And, the link is for SharePoint 2007. The question is clearly tagged as 2010.
    – teylyn
    Mar 14, 2013 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.