Wednesday, February 11, 2015

How to Create SharePoint package (.wsp) as part of the build process in Visual Studio 2012 /2013

Some of you have faced or may have noticed an issue when you create a SharePoint project in visual studio 2012 or 2013 you don't get a option called package like we had in VS 2010.

IN VS 2012 / 2013 we don't have this Package option. so what happen is that when you build a project it only create or update the DLL no WSP creation. WSP create only if you deploy the application through the Visual studio itself 




In VS 2012 or 2013 build commands are not embedded into the project file. so we need to add them manually if we need to create both dll and wsp in the build process.  

there is two way to edit VS project file

1) Unload the SharePoint project from the solution and right click on project then select Edit. The project will open in an editor.

2) Go-to the project location then you will find the CSPROJ File (.csproj) file. then you can edit even using Notepad.



Then add following tag into the following location.

<PropertyGroup>
    <BuildDependsOn>$(BuildDependsOn);CreatePackage</BuildDependsOn>
</PropertyGroup>



you will be asked to Reload the project after this file been saved. now when you build the project dll and wsp file will be created.

ok That's It ... 
HAPPY CODING

Friday, January 30, 2015

Create Custom Picture Library with List Definitions through Visual Studio

One of the major problem we faced when we try to create a picture library through a visual studio that, there is no any Definition type called picture of library, but we can add instance file based on picture library template. if we got a requirement to add a custom columns like we do in normal browser window through a list settings, simply we cannot do through a VS project as we cannot add fields in to a element file.  

When I faced kind of a situation where I need to add Lookup filed in to a Picture Library I did some research and found a one way to do it. here are the steps.

1) Create a Site column ( LookUp Field as follows )

 <Field
       ID="{63F1697D-35B8-40C0-BE33-6CCB44AD35AE}"
       Name="DPMCExternalLink"
       DisplayName="DPMC External Link"
       Type="Lookup"
       List="Lists/ExternalLink"
       ShowField="Title"
       Required="TRUE"
       Group="DPMC Site Columns">
  </Field>

Then create a Content type based in picture content type and added the above mentioned lookup filed in to the content type [ Note : you can added only site columns to the content type ]



[ Note : The feature which deploy  content type ans site column need to be as a site feature ]

2) After that  Create a List and select "Document Library" in SharePoint Customization Wizard window. then click content type button and delete document content type which was the default one and added you newly created content type then make it as a default content type. 






3) In the Library you can see some files been added along with the Instance module, Schema, and Element files. most of them are aspx and htlm file please remove all the aspx and html file. from the library.

4) Then navigate to the 15 hive folder.  TEMPLATE  > FEATURES > PictureLibrary > PicLib
[C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES\PictureLibrary\PicLib]

copy all the aspx and html file then past it into the library. Then set those files Deployment Type as ElementFile.




5) Open schema file of the Picture library and add following fields / tags in to following positions.

ThumbnailSize="160" WebImageHeight="480" WebImageWidth="640" into the "<List xmlns:" tag.
Then <Folder TargetName="Forms/Picture" /> into the Defult content type.



Open Schema.xml  File in the 15 Hive [ \15\TEMPLATE\FEATURES\PictureLibrary\PicLib ] then copy Views and Forms sections from there and replace those in our Schema file . 

Then in the element file  do following changes
Type = "109" [need to change instance element file also]
Sequence = "210"
DocumentTemplate = "100"




ok That's It ... 
HAPPY CODING