Skip to content

Instantly share code, notes, and snippets.

@AsishP
Last active September 12, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsishP/824b4d1a00bf8016d507495107547334 to your computer and use it in GitHub Desktop.
Save AsishP/824b4d1a00bf8016d507495107547334 to your computer and use it in GitHub Desktop.
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.ALM;
using OfficeDevPnP.Core.Pages;
using OfficeDevPnP;
public void DeploySingleApp(Guid appId)
{
using (ClientContext context = new ClientContext(<SiteUrl>))
{
context.Credentials = new SharePointOnlineCredentials(UserName, SecurePass);
AppManager manager = new AppManager(context);
if (manager.Deploy(appId, true))
{
if (manager.GetAvailable(appId) != null)
{
try
{
Task installTask = Task.Run(async () => await manager.InstallAsync(appId));
installTask.Wait();
}
catch (Exception ex)
{
log.Info("Exception Caught - Mostly because the App is already installed. Skipping Install. Message - " + ex.InnerException.Message);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment