0

I have a SPFx list view command set which is deployed tenant wide. More details here

Is it possible to perform the steps mentioned in the article programmatically. Basically I want to upload the package and deploy it via CSOM.

1

It is not possible at the moment using pure CSOM code. It is only possible via REST APIs.

Having said that, you can use PnP CSOM Core library to perform the deployment of SPFx webparts or extensions. It is basically a wrapper over the underlying REST APIs.

To upload the app to the app catalog, you can do that as below:

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 path = @"C:\temp\HelloWorld.sppkg";

    var addApp = appManager.Add(path, true);

}

Once you have uploaded the app, you can then deploy it as below:

var appManager = new AppManager(ctx);

var apps = appManager.GetAvailable();

var customApp = apps.Where(app => app.Title == "Your app title").FirstOrDefault(); // you can check id if you the value of the id of the app

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

Reference - ALM APIs for SPFx

| improve this answer | |
  • Thanks this works! – Garima Jun 12 '19 at 7:25

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.