1

I have created one SharePoint Framework Extension Addin. I have also put it in the SharePoint app catalog site and manually installed it in one of My SharePoint site and it works fine. But now i want to Install or Publish this SharePoint Framework Extension Addin using CSOM code.

So is it possible to install SharePoint Framework Extension Addin into any of my SharePoint site using CSOM? if yes then how?

Thanks in advance.

3

we can use ALM APIs with CSOM for this requirement.

Firstly, you need to install the latest PnP Core dll or PnP PowerShell (Nov 2017 or higher) to perform these operations as these are not supported via OOTB CSOM

Please check the below link for more details and samples

Automating add-in/app installation using ALM APIs with CSOM and PowerShell in SharePoint Online written by SharePoint Stack Exchange user Gautam Sheth

Deploy the app using App Id

string webUrl = "https://tenant-name.sharepoint.com/sites/appcatalog/";

string username = "user.name@tenantname.onmicrosoft.com";
string password = "password";
SecureString secureString = new SecureString();
password.ToList().ForEach(secureString.AppendChar);
var credentials = new SharePointOnlineCredentials(username, secureString);

using (ClientContext ctx = new ClientContext(webUrl))
{
    ctx.Credentials = credentials;

    var appManager = new AppManager(ctx);

    var apps = appManager.GetAvailable();

    var chartsApp = apps.Where(a => a.Title == "Charts 365").FirstOrDefault();

    var deployApp = appManager.Deploy(chartsApp.Id, true);

    //or Deploy the app async
    var deployAppAsync = await appManager.DeployAsync(chartsApp.Id, true);
}

Install the app using AppMetadata

string webUrl = "https://tenant-name.sharepoint.com/sites/test/";

string username = "user.name@tenantname.onmicrosoft.com";
string password = "password";
SecureString secureString = new SecureString();
password.ToList().ForEach(secureString.AppendChar);
var credentials = new SharePointOnlineCredentials(username, secureString);

using (ClientContext ctx = new ClientContext(webUrl))
{
    ctx.Credentials = credentials;

    var appManager = new AppManager(ctx);

    var apps = appManager.GetAvailable();

    var chartsApp = apps.Where(a => a.Title == "Charts 365").FirstOrDefault();

    var installApp = appManager.Install(chartsApp);

    //or Install the app async
    var installAppAsync = await appManager.InstallAsync(chartsApp); 

}
  • can i use the same code under another SharePoint Add-in because i'm trying Install Spfx add-in on multiple sites using my main SharePoint online Add-in. E.g their is two Add-ins Add-in A and Add-in B(SPFX). Now using A i'm going to install B on the Site-1,Site2 etc. – Trimantra Software Solution May 2 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.