How to deploy .wsp file using Visual Studio 2010 for SharePoint 2010

A solution package is a distribution package that delivers your custom SharePoint Server 2010 development work to the Web servers or the application servers in your server farm. Use solutions to package and deploy custom Features, site definitions, templates, layout pages, Web Parts, cascading style sheets, and assemblies.


In SharePoint 2010 it is easy to create a .wsp file using visual studio 2010, which was previously very difficult in MOSS 2007. To deploy any solution package in any local environment in Visual Studio 2010 simply right click on the project and deploy. But to deploy the same thing in the production server we will need to deploy through .wsp file.
Steps to generate the wsp file:
Right click on the project/solution in Visual Studio 2010 then choose package. If you are building the
project/solution in debug mode then you will get the .wsp file inside the Bin\Debug folder and if you are building the project in release mode then you will get the .wsp file inside the Bin\Release folder. This wsp file is needed to deploy in the production environment.

This is the best way to create the wsp file in visual studio 2010.

There are different ways you can deploy the .wsp file
Using browser:
Go to the Central Administration -> Site Actions ->Site Settings -> Galleries –> click on Solutions. After this the below page will open as shown in the figure.
 
Click on Upload solution and then browse to the wsp file as shown below in the figure.
Once you will click Ok then activation window will appear like below figure.
Then you can use the solution.
Using PowerShell:
To add a solution using PowerShell:
Open the SharePoint 2010 Management Shell. You can get to this by going to Start > All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell.
Add-SPSolution {path of wsp file}
 
To deploy the solution using power shell
Install-SPSolution –Identity {path of wsp file}.wsp –WebApplication http://-GACDeployment
 
To update solution
Update-SPSolution –Identity {path of wsp file}.wsp –LiteralPath {local path of wsp file}wsp –GACDeployment
 
To uninstall solution
Uninstall-SPSolution –Identity {path of wsp file}.wsp –WebApplication http://
 
Remove solution
Remove-SPSolution –Identity {path of wsp file}.wsp
 
Using Stsadm:
 
Add the solution
stsadm -o addsolution -filename {path of wsp file}

Deploy the solution

stsadm -o deploysolution -name {path of wsp file} -url {URL}
 
Retract solution:
stsadm.exe -o retractsolution -name {path of wsp file}.wsp –URL
 
Delete Solution
stsadm.exe -o deletesolution -name {path of wsp file}.wsp

Related Posts



To use WebProvisioned event in SharePoint 2010

First of all let us understand what the event is. This is event comes with SharePoint 2010, that allows us to execute something when a sub site in the site collection get created. Here we will see an example that will change the Theme of the sub site when ever the sub site will get created. A point to remember is this event does not fire when the root web site of a new site collection is created. This method can be configured to operate in either synchronous or asynchronous modes. And this can be set in Synchronization tag in the Elements.xml file. To do this we have create an event receiver and we have to write code in the WebProvisioned event, that will responsible to change the Theme of the newly created site.

First open Visual Studio 2010->File ->New Project -> Then from the New Project dialog box go to SharePoint 2010 and choose Event Receiver from the list of Templates. Give the name and location and click on ok as shown in the figure below:

In the next step give the local deployment URL and click on deploy as a farm solution and click on Ok.
Then the SharePoint Customization Wizard will come and here it is important to choose the event receiver settings. Here we will choose the event receiver type as Web Events and then we can choose the events which all we want. Here we only needed the A site was provisioned event. And then click on Finish and the dialog should be as like below figure.

 

Now if you will look at the solution then it should be like the below figure:

Visual studio automatically added Feature as Feature1, Package and our event receiver class as EventReceiver1.
First of all double click on the Feature and change the scope, Here I am changing the scope as Site.
Then lets give a look at the Elements the XML file. Initially Visual studio automatically place the below tag to the elements.xml file:
<?xml version="1.0″ encoding="utf-8″?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers >
<Receiver>
<Name>EventReceiver1WebProvisioned</Name>
<Type>WebProvisioned</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>EventReceiverProject2.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>

My suggestion is do not modify the code. Here one thing to remember is that we can make the event receiver as synchronous or asynchronous. By default it is ssynchronous. If you will make this to Synchronous then any UI changes you will do, it will affect immeditely after the site is created. So lets make the event to Synchronous by adding in Synchronization tag, So our Elements.xml file should look like below now.
And also another point is we need to define the scope here with the Scope attribute of Receivers tag. So the full code will look like below.

<?xml version="1.0″ encoding="utf-8″?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers Scope="Site">
<Receiver>
<Name>EventReceiver1WebProvisioned</Name>
<Type>WebProvisioned</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>EventReceiverProject2.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>
</Receiver>
</Receivers>
</Elements>

Now lets discuss the EventReceiver1 class.
Visual studio automatically put the below code, with the override WebProvisioned method. The code is: using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace EventReceiverProject2.EventReceiver1
{ ///

/// Web Events
///

public class EventReceiver1 : SPWebEventReceiver
{
///

/// A site was provisioned.
///

public override void WebProvisioned(SPWebEventProperties properties)
{
base.WebProvisioned(properties);
}
}
}

In the override method we will define the code that will change the theme. So the full code will be

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace EventReceiverProject2.EventReceiver1
{
///

/// Web Events
///

public class EventReceiver1 : SPWebEventReceiver
{
///

/// A site was provisioned.
///

public override void WebProvisioned(SPWebEventProperties properties)
{
try
{
base.WebProvisioned(properties);
SPWeb web = properties.Web;
web.Navigation.UseShared = true;
string ThemeURL = "[Your Site URL]/_catalogs/theme/Mission.thmx";
ThmxTheme.SetThemeUrlForWeb(web, ThemeURL);
web.Update();
}
catch (Exception ex)
{
throw;
}
}
}
}

Here you can check the theme url from the Theme galery. That is it.
Then build the solution and then deploy the solution. It will automatically attach the event receiver. Else for deployment you can follow this :

Then try to create a site and see the site's theme after that.

Related Posts



How to put people into the Site Permissions groups of SharePoint site

Also you can add users to different groups into the site or also you can remove users from the SharePoint groups. To add users go to Site Actions ->Sit Permissions as shown in the figure below.

 

This will open the Permissions page as shown in the figure below.
Here you can see groups like Members, Owners, Visitors, Viewers etc.

In the ribbon there are options to give permissions to users, also options to create group etc. Also you can add users to existing groups.

To grant permissions, click on the Grant Permissions link from the Ribbon which will open the Grant Permission dialog as shown in the figure below:
Here in the Select Users add the user and in the Grant Permissions section you can add the above user to any existing user group by selecting the first radio button or you can you can also grant permission directly by choosing the 2nd radio button. And in the Send E-Mail section, If you want to send a wel come main then you can check the Send Welcome mail check box and also you can add your personal message. Then click on OK.

If you want to add users to existing permissions group then click on the group on which you want to add user as shown in the figure below.

This will open the user group page. There to add a new user click on the New -> Add Users as shown in the figure below.
This will open of the Grant Permissions dialog as show in the figure below:
In this dialog add the user name and you can add any number of users and Send E-Mail section you can select the check box to send the email to user and also you can write the personal message also.

Related Posts



How to Create SharePoint permission group in SharePoint 2010

SharePoint 2010 provides different permission groups by default like Members, Owners, Visitors, Viewers etc. But all SharePoint Administrators can be able to add new SharePoint security groups to SharePoint 2010 site collection. To create a new group. go to Site Actions -> Site Permissions as shown in the figure below.

  

In this page you can be able to see all the default groups also. And from the ribbon click on Create Group as shown in the figure below to create a group.

 

This will open the Create New SharePoint Group page. And in this page, Give a name for the group, Description for the group and also the Group owner and the membership of the group like who can view and edit the group as shown in the figure below.
 
 
 
And also in the Membership request section you can do the settings and Give permission to site is an important section since we are giving permissions to the site. You can choose from the list of permissions like Full Control, Design, Contribute, Read, View only etc. as shown in the figure below, then click on create and our new group will create.
 
Then you can add users to that group by following this:

Related Posts



How to Restore a Site Collection in SharePoint 2010

Before restoring a site collection, you can check  how to take backup of a site collection.
There are different ways that you can restore a site collection in SharePoint 2010 like stsadm, powershell.
Stsadm:
Here is the command to take backup of site collection:
STSADM -o restore -url -filename [-overwrite]
Example:
STSADM -o restore -url http://your-site-url -filename c:\backup\MySiteCollection.bak
PowerShell:

Here is the powershell command to restore a site collection.
Restore-SPSite -Path [-force]
Also there are lots of parameters of this command.
Example:
Restore-SPSite http://your-site-url -path c:\backup\MySiteCollection.bak [-force]

Related Posts



How to Backup of Site collection in SharePoint 2010

There are different ways that you can take backup of a site collection in SharePoint 2010 like stsadm, powershell or through central administration. First we will see how we can take backup through central administration.

First open your SharePoint 2010 central administration, go to Backup and Restore section and click on Perform a site collection backup. Then it will open the Site collection backup page like below figure. There choose the site collection for which you want the backup and give the file name and path in the file location and click on Start Backup.

Stsadm:

Here is the command to take backup of site collection:

STSADM -o backup -url <SiteCollectionURL> -filename <filename>

Example:

STSADM -o backup -url http://your-site-url -filename c:\backup\MySiteCollection.bak

PowerShell:

Here is the powershell command to take backup of a site collection.

Backup-SPSite <SiteCollectionURL> -Path <filename>

Also there are lots of parameters of this command.

Example:

Backup-SPSite http://your-site-url -path c:\backup\MySiteCollection.bak

You can check how to restore a site collection from the backup file.

Related Posts



How to Use HTML5 and CSS3 with SharePoint 2010

about HTML5 and SharePoint. HTML5 is certainly the future of the Web, but as a person that leans toward the design side of things, I really think CSS3 is way more exciting. Here are some of the features that HTML5 adds beyond what we already have with prior versions: 
• SVG vector graphics – Support for Scalable Vector Graphics 
• Canvas element – The ability to draw on the page in two dimensions 
• Video & audio elements – Otherwise known as the Flash killer 
• Semantic elements – <header>, <footer>, etc. 
• New input element types and form fields – Input types and new form fields 
• Geolocation – Identify the physical location of the browser 
• Persistent Local Storage – Store content locally with plugins 
• Other random additions – Drag & drop, microdata, WebSockets, etc. 
CSS3 on the other hand adds all sorts of exciting design concepts, including: 
• Border shadows, rounding and images 
• Background sizing 
• Text shadows and wrapping control 
• Better support for Web fonts 
• 2D and 3D transformations 
• Visual transitions 
• Animations 
• Support for creating columns on the page 
Unfortunately, browser support for CSS3 is hit or miss from a specific functionality point of view. W3Schools.com has a good chart on which browser versions support which things. 
Trying it out 
I'm sure you are saying, "OK, that's all fine and dandy, but how does any of this work in SharePoint 2010?" To try out CSS3 in a SharePoint 2010. all you have to is change the line in a typical SP2010 master page that tells IE to render the page in IE8 mode: 
<meta http-equiv="X-UA-Compatible" content="IE=8"/> 
Change that to IE=9 and you should be in business for testing any CSS3 code that IE9 can display. 
For trying out HTML5 content, you should make the same change for the IE version, but you will also want to change the DOCTYPE from: 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
To: 
<!DOCTYPE HTML> 
With those two changes in place, you can start testing HTML5 content in SharePoint 2010. 
Some warnings 
Before you get too into this new markup, there are some warnings I should tell you about. First and foremost, SharePoint 2010 was not developed with IE9 or HTML5 in mind. While it should work pretty well, this was not the initial test scenario for the product team, and as such you may run into unexpected issues. Be sure to thoroughly try this in a test environment first. 
Second, there are some issues with HTML form fields when SharePoint is rendering in IE9 mode. You can see this problem quickly by trying to add a new item to a SharePoint calendar; the HTML field for the description doesn't work properly. Unless you can figure out a workaround for this (and I haven't yet), you may find using HTML5 for intranet sites to be challenging. 
An example 
I'll close with a quick example of some HTML5 and CSS3 being used in a SharePoint 2010 Content Editor Web Part (the code for both comes from W3Schools.com):

1116.sp-sharepointers

Because the Content Editor Web Part can be annoying when working with JavaScript directly, I usually link it to an HTML file placed in the Style Library. The code for the HTML file in this example looks like this: 
<h1>HTML5 Canvas Example:</h1> 
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;"> 
    Your browser does not support the canvas element. 
</canvas> 
<script type="text/javascript"> 
var c=document.getElementById("myCanvas"); 
var cxt=c.getContext("2d"); 
cxt.fillStyle="#FF0000"; 
cxt.beginPath(); 
cxt.arc(70,18,15,0,Math.PI*2,true); 
cxt.closePath(); 
cxt.fill(); 
</script> 
<h1>CSS3 Border Radius Example:</h1> 
<style type="text/css"> 
    .rounded { 
        width:100px; 
        height:100px; 
        background-color:red; 
        border:2px solid; 
        border-radius:2em;         
    } 
</style> 
<div class="rounded"></div>

Related Posts