Sunday, October 7, 2012

SharePoint - C# solution deploy

If you have C# Sharepoint solution and you need to deploy it to a production machine, the easiest way is to use Powershell.

First you need to get your solution on your dev machine:

1. Start -> All Programs -> Sharepoint 2010 Products -> Sharepoint 2010 Managementshell (open with "Run as administrator").

Write these commands:

2. $farm = Get-SPFarm
3. $file = $farm.Solutions.Item("MyProjectName.wsp").SolutionFile
4. $file.SaveAs("c:\temp\MyProjectName.wsp")

If you now type command "$file", you should see properties of your saved file:



 Now go to production machine, where you would like to deploy solution:

1. Copy solution file from dev (which is in c:\temp\)  to production machine (let's say to c:\temp\)

2. Start -> All Programs -> Sharepoint 2010 Products -> Sharepoint 2010 Managementshell (open with "Run as administrator").

Write these commands:

3. Add-SPSolution "C:\temp\MyProjectName.wsp"
4. Install-SPSolution -Identity MyProjectName.wsp -GACDeployment

Wait for about 10 seconds and check if deploy was successful:

5. Get-SPSolution -Identity MyProjectName.wsp
 

column "Deployed" should be set to "True".

That's it, your solution is now deployed. You can now go to your Sharepoint Site Settings and activate feature named MyProjectName in Site Collection Features.

If you want to remove solution, you can do it with these commands:

1. Uninstall-SPSolution -Identity MyProjectName.wsp -confirm:$false
2. Remove-SPSolution -Identity MyProjectName.wsp -confirm:$false

No comments:

Post a Comment