Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to find a way how to update a SharePoint solution programmatically with C#. (I already know how to do this with the powershell command Update-SPSolution).

I have tried using this code but it doesn't work:

SPSolution sol = SPFarm.Local.Solutions[name]; //name = mytest.wsp
sol.Upgrade(filePath); //C:\mytest.wsp

Can anyone provide some guidance?

share|improve this question
1  
How is it not working? What is your Farm topology? (Number of front ends etc.) If it is a multi front-end farm try to use the Upgrade overload with a DateTime parameter to schedule a TimerJob, this will execute on all Web servicers. msdn.microsoft.com/en-us/library/… –  Robert Lindgren Jul 4 '13 at 10:25
    
what do you mean by "it doesn't work" you must get some kind of error, try using ULS Viewer to capture error if nothing comes up in event receiver –  Muhammad Raja Jul 4 '13 at 13:29
    
At the moment it is a Dev-Server with all components (MSSQL, Front-End) on one system. –  AHO Jul 8 '13 at 7:17
    
"It doesn't work" means that nothing happens :-( –  AHO Jul 8 '13 at 7:19

1 Answer 1

You are using the correct code (see http://msdn.microsoft.com/en-us/library/office/ms455619.aspx). When I do this, I usually specify DateTime.Now for the second parameter. This code schedules a deployment job the same way the Update-SPSolution Cmdlet does.

What I would suggest is to run this code and then immediately refresh the Farm Solutions page to see if there is a change in status. Additionally you could use this PowerShell to see if a deployment job exists:

Get-SPTimerJob | Where-Object { $_.Name -Match "solution-deploy" }

Additionally you can check the solution itself for an existing job:

(Get-SPSolution solution.wsp).JobExists

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.