Các lệnh để thêm hoặc triển khai Solution trên SharePoint 2010

1. Cách thêm solution thông qua Visual Studio:

Visual Studio 2010 makes it really easy to add and deploy solutions when you are developing, but you may eventually want to deploy those solution packages elsewhere right? We can still use stsadm, but that is effectively considered deprecated now in favor of PowerShell. In the past to add a solution, we used an stsadm command like the one below. In today’s example, we’ll be working with a package called SR.UI.WebPart.NivoSlider.wsp on my server named sp2010.

stsadm –o addsolution –name SR.UI.WebPart.NivoSlider.wsp

To get started with PowerShell, run the SharePoint 2010 Management Console located in your Microsoft SharePoint 2010 Products folder on your start menu. This automatically loads the Microsoft.SharePoint.PowerShell snappin so that we can execute SharePoint commands.


2. Cách thêm solution thông qua SharePoint PowerShell khi đã được đóng gói Solution:

To install a solution we use the Add-SPSolution command. If you are using a Sandboxed solution you would use Add-SPUserSolution instead. It takes just one parameter, –literalpath, which is the path to the solution file. One thing that is different is that you must specify the full path to the file for some reason. I haven’t been able to get it to take a path to the solution in the current folder even if I make use of .\ before the filename. Here is an example.

Add-SPSolution c:\code\sps2010Project\bin\debug\SR.UI.WebPart.NivoSlider.wsp

In this case you don’t actually have to type –literalpath before the parameter. This is what it looks like when executed. You can see that it displays the id of the solution along with its deployment status.


3. Cách Deploy solution thông qua SharePoint Center Administrator:

Trước lúc dùng lệnh Add-SPSolution truy cập màn hình Solution Management có thể bạn không thấy các gói Solution (chỉ có thông báo cần dùng lệnh stsadm –o addsolution  để thêm gói solution).

Sau khi bạn chạy 1 trong 2 cách trên, thì refresh màn hình Solution Management, bạn sẽ thấy ngay gói Solution đẽ được add thêm vào, việc còn lại là bạn

bấm chọn tên gói solution nói trên: hãy chọn chế độ Deploy và chọn các site cần để cài vào trước khi sử dụng gói Solution này.


4. Cách Deploy solution thông qua SharePoint PowerShell khi đã được add thêm Solution từ Visual Studio/PowerShell:

Now we need to deploy the solution. In the past, we used an stsadm command like the following.

stsadm –o deploysolution –name SR.UI.WebPart.NivoSlider.wsp –url http://sp2010 –allowCasPolicies –immediate

We would also follow this up with a call to stsadm with the execadmsvcjobs operation. To do the same operation in PowerShell, we use the Install-SPSolution command (again use Install-SPUserSolution for Sandboxed solutions). You can use the Get-Help command (i.e.: Get-Help Install-SPSolution) to get more information on a command but it’s not always obvious what it is expecting as you can see below. That is why I am writing the post today.


The first parameter you need is the –Identity parameter. This is the name of the solution package (i.e.: MySolution.wsp). Depending on if you are using the GAC or Code Access Security, you will specify either –GACDeployment or –CASPolicies. You then need to specify a specific web application using the –WebApplication parameter or –AllWebApplications to deploy it to all web applications (assuming the manifest allows it). If you need to force the deployment, you can still use the –Force command. Here is what an install command might look like.

Install-SPSolution –Identity SR.UI.WebPart.NivoSlider.wsp –WebApplication http://sp2010 -GACDeployment

I’ll point out that executing this command actually does do the deployment operation. You don’t have to fire off something to execute a job later like you did with stsadm.

You might want to update your solution, so we’ll talk about how to do that as well. Here is what your stsadm command might have looked like in WSS3. Which would also be followed up with an execadmsvcjobs operation.

stsadm –o upgradesolution –name SR.UI.WebPart.NivoSlider.wsp –filename SR.UI.WebPart.NivoSlider.wsp –immediate –allowCasPolicies

The upgrade solution syntax is similar to the others. We just have to specify an identity and a literalpath with the Update-SPSolution command. The identity is the name of the package on the server to upgrade and the literalpath is the full path to the new solution package on the file system. Here is what that might look like.

Update-SPSolution –Identity SR.UI.WebPart.NivoSlider.wsp –LiteralPath c:\code\Sp2010Project\bin\debug\SR.UI.WebPart.NivoSlider.wsp GACDeployment

We’ve talked about everything else, so we’ll finish it up by talking about retraction and removal. To retract a solution we use the Uninstall-SPSolution command. By now you are probably noticing a pattern in the way things are named. Install –> Deploys, Uninstall –> Retracts. It also just uses the -Identity parameter and the –WebApplication parameter. You can also use the –AllWebApplications parameter to retract it from all web applications. Many of these commands may prompt you with an “Are you sure?” type prompt. You can skip this prompt by adding a –confirm parameter. Here is what it looks like.

Uninstall-SPSolution –Identity SR.UI.WebPart.NivoSlider.wsp –WebApplication http://sp2010

Lastly, to remove the package from the solution store, we use the Remove-SPSolution command. It just takes the name of the package.

Remove-SPSolution –Identity SR.UI.WebPart.NivoSlider.wsp


5. Kích hoạt gói Solution cho phép chạy trên Site mà bạn cần dùng:

OPTIONAL STEP (You can do it when necessary):

Now you have to enable this feature at the website to use it. To do it follow these steps:

Enable the features at the website>> Go to your Site settings> Site Collection Administration > Site collection features

And activate the feature (SR.UI.WebPart.NivoSlider ,for example) that you have installed. And add that webpart to your site to test.


6. Xoá gói Solution trong máy chủ Farm:


Hy vọng là các bạn sẽ thành công !


About thangletoan

Hallo Aloha

Posted on 27/05/2010, in Công nghệ và Giáo dục, Deloyment, Microsoft, Microsoft Office SharePoint, Microsoft SharePoint, ROBUSTA Training & Best Trainer, SharePoint, Solution, SPS2010 and tagged . Bookmark the permalink. Bạn nghĩ gì về bài viết này?.

Trả lời

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Đăng xuất /  Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Đăng xuất /  Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Đăng xuất /  Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Đăng xuất /  Thay đổi )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: