In this blog, I will give you the list of steps to automate SharePoint ADD IN's deployment, using CSOM.
- ClientContext cctx = new ClientContext(myurl);
- cctx.AuthenticationMode = ClientAuthenticationMode.Default;
- cctx.Credentials = new SharePointOnlineCredentials(userName, pwd);
-
-
- 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;
- }
-
- site.DeactivateFeature(sideloadingFeature);
- }
- catch (Exception ex)
- {
-
- Console.WriteLine(string.Format(“Exception!”), ex.ToString());
- Console.WriteLine(“Press any key to continue.”);
- Console.Read();
- }