Build your first add-in

This tutorial demonstrates how to create and run a basic ArcGIS Pro add-in.

With ArcGIS Pro SDK for .NET, you can extend ArcGIS Pro with your own unique tools and workflows. Using Microsoft Visual Studio and the Pro SDK, developers can build Pro add-ins and solution configurations that provide users with custom functionality specific to their organization or industry. Add-ins can be developed and tailored to your specific users’ needs; for example, providing a new custom spatial analysis processing routine which leverages a custom dataset, or create a new set of Pro tools that streamline a complex editing workflow.

This tutorial is an introduction to developing ArcGIS Pro add-ins. You will use C# to create a new button which returns the current project path on the ArcGIS Pro UI.

Prerequisites

Steps

Create a new ArcGIS Pro Add-In Visual Studio Project

  1. Start Visual Studio.

  2. Choose File > New > Project and then from ArcGIS templates group, select ArcGIS Pro Module Add-in.

    By default, the Config.daml file opens in Visual Studio. The Module1.cs file contains add-in module code.

    Note also in the Config.daml file that the id attribute of the insertModule tag matches the ID within the Module1.cs file and that the className attribute matches the class name of the module.

    To find the ArcGIS templates group, see Templates > Visual C# > ArcGIS. Also confirm that the latest .NET Framework is selected.

  3. Compile and build the project.

    If you have errors in your output window, confirm that you have correctly installed ArcGIS Pro and the ArcGIS Pro SDK for .NET. As long as you have not changed the syntax in any of the generated files (from the Project template), there should be no compilation errors.

  4. From Windows Explorer, navigate to C:\Users\<Your user name>\Documents\ArcGIS\AddIns\ArcGISPro. You should see the add-in folder for your newly compiled add-in. Double-click the folder to find your add-in file within the folder, reflecting the name of your project with an .esriAddinX extension. The name of the folder corresponds to the ID (GUID) of your add-in as found in your Config.daml file.

Create a new button using a Pro SDK template

  1. If your project is running, stop it. In the Solution Explorer, right-click the project and choose Add > New Item and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Button from the list of item templates.

  2. Use the default name of Button1.cs for the new class file and press Add to close the dialog box.

    The Button1.cs file should open by default. If not, open the file. See the ArcGIS Pro wiki for more information on the Pro Button template.

  3. Type the following code into the existing OnClick method.

    The OnClick method was automatically generated by the template.

    The first line creates a string variable which contains the project’s URI path; the second line shows a simple dialog box containing the value of the string variable with the path and a caption.

      
    1
    2
     string stringURI = ArcGIS.Desktop.Core.Project.Current.URI;
     ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Project path:  {stringURI}", "Project Info");
  4. Compile and build the add-in project.

Run the project

  1. Place a breakpoint in the margin of the stringURI variable declaration, and then press Start to run the add-in project in the Visual Studio debugger. ArcGIS Pro will start and show the start page.

  2. From the start page, create a new empty project using a template of your choice or open an existing project. If creating a new project, specify a name and location of your choice.

  3. Once the project opens, click the Add-In tab. Click your new button, named Button1, which used the default name of your button class. Your breakpoint will be hit in Visual Studio which you can review in your code.

  4. Press F5 or Continue to continue execution. The message box should display with the project path. Press OK to close the message box.

  5. Press Stop Debugging in Visual Studio, which will close ArcGIS Pro.

What's next?

Learn how to use additional ArcGIS Pro for .NET SDK features in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.