Last active
September 12, 2018 11:59
-
-
Save AsishP/824b4d1a00bf8016d507495107547334 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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