How to automate the sharepoint ADD IN’s deployment using CSOM in sharepoint online/Office 365?
Hello SharePointers,
In this blog, I will give you the list of steps to automate the SharePoint ADD’in deployment using CSOM.
ClientContext cctx = new ClientContext(myurl);
cctx.AuthenticationMode = ClientAuthenticationMode.Default;
cctx.Credentials = new SharePointOnlineCredentials(userName, pwd);
// Get Site Information.
Site site = cctx.Site;
Web web = cctx.Web;
try
{
site.ActivateFeature(sideloadingFeature);
try
{
var appstream = System.IO.File.OpenRead(path);
AppInstance app = web.LoadAndInstallApp(appstream);
cctx.Load(app);
cctx.ExecuteQuery();
}
catch
{
throw;
}
//Disable SideLoadingfeatures
site.DeactivateFeature(sideloadingFeature);
}
catch (Exception ex)
{
Console.WriteLine(string.Format(“Exception!”), ex.ToString());
Console.WriteLine(“Press any key to continue.”);
Console.Read();
}
Happy SharePointing folks 🙂