3

In Visual Studio 2015 I have created a new solution based on the "SharePoint Add-in" template. As I have chosen to make it a provider-hosted add-in I have two projects created: sharepoint-addin and sharepoint-addinWeb.

I am finding that every time I deploy my add-in to SharePoint Online by hitting F5 in Visual Studio, the add-in's id changes. I see this both in a change to the ClientId appSetting in the web.config of the sharepoint-addinWeb project and online in the SharePoint Admin Center's App Permissions page.

Why does the id change with every deployment and how can I set the id to a fixed value?

4

As explained in detail in the MSDN article "Register SharePoint Add-ins 2013" the regeneration of the ClientId is part of a feature of Microsoft Office Developer Tools for Visual Studio described as "temporary registration".

I've found a way to work around this feature and build and debug my add-in in Visual Studio without having its ClientId change every time. The key is to disable the publishing of the add-in project entirely.

Here are the steps to get this done:

  1. Go to the solution's Property Pages dialog.
  2. Under Common Properties > Startup Project set the SharePoint Add-in project's Action to "None".
  3. Leave the add-in server-side project set to "Start".
  4. Click OK.

See screen shot for reference:

Solution Property Pages dialog

2

When you deploy the add-in to SharePoint host web using visual studio, it gets installed (if its already present, the add-in is retracted first) as a new add-in every time. As part of this process visual studio generates and registers new client id for the add-in along with the required add-in principal behind the scene and also updates the config file of the remote web with the newly registered client id.

You need not deploy the add-in every time you make the change in your remote web. You can configure your add-in and manifest and deploy it once. Subsequently you only need to deploy the remote web in case you make changes to it which is automatically picked up by the add-in. Remember that add-in just holds the reference (URL) to your remote web in its manifest file.

Hence deploy your SharePoint add-in project only when you make changes (manifest/principal etc.) to it and not every time.

  • Thanks but I still need to have the client id set to a fixed value. My add-in is still in initial development and changes to the manifest are frequent. – urig Apr 5 '16 at 20:16
  • Open your appmanifest.xml file in code view and add an already registered client-id to ClientId attribute of RemoteWebApplication tag under AppPrincipal. – Vineet Desai Apr 5 '16 at 20:24
  • Tried it. When I deploy with F5 I get an exception that mentions this URL: oauth.sellerdashboard.microsoft.com/… (I'm guessing this is an attempt to post my add-in to the sellers' dashboard but I'm not even registered there) – urig Apr 6 '16 at 19:50
1

What you have to do is simply register your application using _layouts/15/appregnew.aspx.

Ex:

Client Id    :   Genarate
Client Secret:   Genarate
Title        :   AppTitle
App Domain   :   localhost:44310(the remote  Web application Domain with the port, if has)
Redirect URI :   https://localhost:44310 ( Remote web application URL)

Then modify the Web.config file of the web application with generated Client Id and Client Secret. Modify the Client Id in App Manifest also.

Then when you run the solution using F5 the app id will not change.

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.