Online Training On SharePoint

Monday, 28 February 2011

New Project Templates in Visual Studio 2010 for SharePoint 2010

Visual Studio 2010 offers rapid solution development capabilities for SharePoint 2010. There are around 20 new templates including Project Type and Project Item templates. Here are the details mentioning the same:

New Project Type Templates in Visual Studio 2010:

Business Data Connectivity Model: This template is used to build a BCS model that allows connecting SharePoint to the line-of-business systems, databases, or web services. VS also include a graphical designer for BCS models.

Content Type: Use this template to create a custom content type. Though there is no graphical designer for content types, VS does support IntelliSense for creating the XML to define new content types.

Empty SharePoint Project: This template allows setting up an empty project that has all the necessary elements, such as folders for references, features, solutions, and a key to strong name the assembly.

Event Receiver: This template helps to start writing event receivers. Event receivers can be on a List, List Item, List Email, Web, or List Workflow event. VS will create the event receiver class, which can be customized for the application.

Import SharePoint Solution Package: This template allows importing an existing WSP.

Import Reusable Workflow: This template allows importing an existing reusable workflow that is created in SPD, which can then customize and deployed from VS. The import is one way, and once it is modified in VS, we cannot take this workflow to back to SPD.

List Definition: We can create a list definition and list instance using this template. We can base our list on the Announcements, Calendar, Contacts, Custom List, Document Library, Links, or Tasks list types only.

Module: A module type allows adding additional fi les to our SharePoint projects. By default it includes an Elements.xml file and a sample.txt file that we can modify to meet our needs or we can add new files to the module as required.

Sequential Workflow: This template creates a new sequential workflow. The workflow can be a list or site workflow, and we can use the graphical workflow design tools to create our workflow in VS.

Site Definition: This template allows creating a new site definition. Once it is created, VS will add a number of files for this project type, including a default ASPX page; a onet.xml file, which defines the items in the site; a global resource file; local resource files; and a webtemp file used to tell SharePoint about the site.

State Machine Workflow: This template creates a new state machine workflow. We can use the graphical workflow design tools in VS to modify our workflow.

Visual Web Part: This template creates a new Visual web part, which allows us to drag and drop controls onto our web part for your user interface rather than having to write the user interface in code. It contains a web part and a User Control item.

New Project Item Templates in Visual Studio 2010:

Application Page: Use this template to create an application page, which is just an ASP.NET page hosted in SharePoint.

Business Data Connectivity Resource Item: Use this template to create a resource file for your BCS model. A resource file allows localizing the names in the model and applying permissions to objects.

Empty Element: This template creates an elements.xml file that allows to define SharePoint artifacts using XML. The most common usage would be defining a field in your SharePoint project.

Global Resources File: Use this template to create a resource fi le, which will contain all the localized text strings for your project.

List Definition from Content Type: This template creates a list definition based on a content type in your project.

List Instance: This template creates an instance of a list by generating a new instance and an elements.xml file that describes the properties for the instance.

User Control: You can create a user control that you can use in an application page or web part with this template. You can design the control using the graphical designers in VS by dragging and dropping your controls onto the design surface.

Web Part: This template allows you to create a web part for your SharePoint environment.

Workflow Association Form: This template allows creating a form that is displayed when a workflow is associated with its intended target, such as a list. The form will be an ASP.NET form, and the template creates two files, a Designer file and your code - behind file. We can use this form to collect any properties we need from the user for your workflow to create the workflow instance.

Workflow Initiation Form: This template creates a workflow initiation form, which is used when the workflow is activated. This template creates a Designer and a code behind file for your ASPX form.

Saturday, 26 February 2011

Retriving SharePoint WSP Files from Config DB using SharePoint Object Model and PowerShell

WSP files are the preferred way of deploying the new functionlaity in SharePoint. WSP files are stored in the Config DB. If you need to extract these files you can do that by using the SharePoint Object Model Code. The following code snippet will retrive all the solutions from the config DB and will place them in the specified location:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration; 

namespace Retrive_Solutions 
    class SolutionBackup 
        static void Main(string[] args) 
            SPSolutionCollection AllSolutions = SPFarm.Local.Solutions; 
            foreach (SPSolution Solution in AllSolutions) 
                SPPersistedFile wspFile = Solution.SolutionFile; 
                wspFile.SaveAs("C:\\Solutions\\" + Solution.Name); 

The same also can be achieved using PowerShell so no need to write any OM code. Here is the PowerShell script to acheive the same:

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local 

$path = Split-Path $MyInvocation.MyCommand.Path 
[Void]( ni "$path\Solutions" -type Directory -force ) 

$farm.Solutions |% { 
  Write-Host $_.Name 
  $solution = $_.SolutionFile 
Related Posts with Thumbnails