locked
Adding and activating solution in solution gallery RRS feed

  • Question

  • Folks,

    I am trying to activate wsp from solution gallery but not able to do so. This is my client requirement and i want to upload solution from my file structure to SharePoint and then want to activate it. Anybody have solution for it?

    -Minesh

    Monday, October 27, 2014 2:18 PM

Answers

  • Hi Minesh,

    I had similar requirement in my project and i wrote below segment to achieve my task.

    ClientContext context = new ClientContext("http://in-air-eyshr2:1234/sites/ETD02");

    //Activate Publishing feature 

    //Add wsp from file system to SP solution gallary

    Folder destionationFolder = context.Web.GetFolderByServerRelativeUrl("_catalogs/solutions");

    FileCreationInformation fci = new FileCreationInformation();

    fci.Content = System.IO.File.ReadAllBytes("D:/WSPS/LDTest.wsp");

    fci.Url = "LDTest.wsp";

    fci.Overwrite = true;

    Microsoft.SharePoint.Client.File fileToUpload = destionationFolder.Files.Add(fci);

    context.Load(fileToUpload); context.ExecuteQuery();

    //Activate solution DesignPackageInfo info = new DesignPackageInfo()

    {  

    PackageGuid = Guid.Empty,   MajorVersion = 1,   MinorVersion = 1,   PackageName = "LDTest"   };   Console.WriteLine("Installing design package ");  

    //Relative Path of Solution Uploaded in Solution Gallery  

    //string fileRelativePath = "D:/WSPS/testwsp.wsp";

    string fileRelativePath = "/sites/ETD02/_catalogs/solutions/LDTest.wsp";

    DesignPackage.Install(context, context.Site, info, fileRelativePath);

    context.ExecuteQuery(); Console.WriteLine("Applying Design Package!");

    DesignPackage.Apply(context, context.Site, info); context.ExecuteQuery();

    and it gave me following output:

    

    I also wrote about it on my blog:

    http://knowledgegrip.blogspot.in/2014/09/adding-and-activating-solution-in.html 

    Let me know if this helps.

    

    Monday, October 27, 2014 2:36 PM

All replies

  • Hello Minesh

    here am using powershell cmdlets.

    1. add solution to sharepoint

    Add-SPSolution “D:\Sample4WSP.wsp”

    2. Deploy solution to a webapplication

    Install-SPSolution –Identity Sample4WSP.wsp –WebApplication http://SP2010 –GACDeployment

    or you can deploy from Central Administration.

    3. Activate feature( without activating the feature we cannot see this webpart in webpart gallery).

    Enable-SPFeature –Identity Sample4WSP_Feature1 –url http://demoshare:8086

    to confirm whether the feature is activated or not we have to execute another command that will show all activated features

    “get-spfeature -site http://demoshare:8086 | sort displayname”


    Thanks and Regards Rahul Dagar

    Monday, October 27, 2014 2:27 PM
  • Hi Minesh,

    I had similar requirement in my project and i wrote below segment to achieve my task.

    ClientContext context = new ClientContext("http://in-air-eyshr2:1234/sites/ETD02");

    //Activate Publishing feature 

    //Add wsp from file system to SP solution gallary

    Folder destionationFolder = context.Web.GetFolderByServerRelativeUrl("_catalogs/solutions");

    FileCreationInformation fci = new FileCreationInformation();

    fci.Content = System.IO.File.ReadAllBytes("D:/WSPS/LDTest.wsp");

    fci.Url = "LDTest.wsp";

    fci.Overwrite = true;

    Microsoft.SharePoint.Client.File fileToUpload = destionationFolder.Files.Add(fci);

    context.Load(fileToUpload); context.ExecuteQuery();

    //Activate solution DesignPackageInfo info = new DesignPackageInfo()

    {  

    PackageGuid = Guid.Empty,   MajorVersion = 1,   MinorVersion = 1,   PackageName = "LDTest"   };   Console.WriteLine("Installing design package ");  

    //Relative Path of Solution Uploaded in Solution Gallery  

    //string fileRelativePath = "D:/WSPS/testwsp.wsp";

    string fileRelativePath = "/sites/ETD02/_catalogs/solutions/LDTest.wsp";

    DesignPackage.Install(context, context.Site, info, fileRelativePath);

    context.ExecuteQuery(); Console.WriteLine("Applying Design Package!");

    DesignPackage.Apply(context, context.Site, info); context.ExecuteQuery();

    and it gave me following output:

    

    I also wrote about it on my blog:

    http://knowledgegrip.blogspot.in/2014/09/adding-and-activating-solution-in.html 

    Let me know if this helps.

    

    Monday, October 27, 2014 2:36 PM
  • Hi Hirwani,

    Thank you so much. I think i am looking out for this solution. I am going through your post :) 

    -Minesh

    Monday, October 27, 2014 2:43 PM