1

I am able to install/deploy an app to a sharepoint site using the code below

var appManager = new AppManager(context);
var apps = appManager.GetAvailable();
var foundApp = apps.Where(a => a.Id == FeatureId).FirstOrDefault();
var installAppAsync = await appManager.InstallAsync(foundApp);

However, one particular app needs to be tied to a specific document library when added to a site, how can I specify these parameters when installing the app?

2

If you're developing a custom command set for a list, after installing the SPFx package to the app catalog, you need to attach your command set to the target list with the code:

var list = clientContext.Web.Lists.GetById(listId);
var customActions = list.UserCustomActions;

var customAction = customActions.Add();
customAction.ClientSideComponentId = new Guid("Id of your command set");
customAction.Location = "ClientSideExtension.ListViewCommandSet.CommandBar";
customAction.Update();
clientContext.ExecuteQuery();

Please, note that your package must be either tenant-wide scoped or deployed to the app catalog of the target site collection.

  • There is a mixture of Apps that I need to add, some are ProviderHostedEventReceivers, others are commands like your example. Its the EventReceivers and the like that I need to add to the site. – Mauro Oct 9 at 7:32
  • You cannot attach event receivers with an app, you can do that programmatically only: sharepointnutsandbolts.com/2014/01/… – Dmitry Kozlov Oct 9 at 7:39

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.