Question

I have one Document Library in central administration Name "Deployment List" it contains SharePoint Solutions(WSP files). now i want to add and deploy that solution using c# code it already get file and deploy it form Local drive but i want to get that file(WSP file from Document Library). I am using Timer job to deploy that solution Note : Solution are farm solution

my code is as follow :

try
{
    // It give Error below line that "File not Found"
    SPSolution solution = SPFarm.Local.Solutions.Add("http://centraladmin/Deployment List/MySolution.wsp"); 

    Collection selectedWebApps = new Collection();

    SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://localhost:80"));

    selectedWebApps.Add(webApp);

    solution.DeployLocal(true, true);
}
catch
{
}

I get "File not found" exception when i try to add the solution to the farm.

Any idea how to solve this error?

Was it helpful?

Solution

Well you didn't specify an error, but I am guessing it doesn't know what you are talking about when you give it that url.

When you deploy to SharePoint it expects a physical file in a physical location.

I had a similar problem trying to parse the contents of .doc files from the old 2003 Office library.

We ended up downloading the file to the filesystem, processing it, then deleting it from the filesystem. The same would work here and you would maintain the transparency you are looking for.

Download the file to the server filesystem

Deploy the file

Delete the file from the filesystem

OTHER TIPS

Your code does not work as the Solution.Add method expects a System.IO.Path, not a Uri. You need to specify a valid Path (UNC, local path, etc.) when using Solution.Add("path").

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top