Now that you have your package created, let's add an activity to it! In this example, you will create the activity shown above: a simple one that adds two numbers together.
Start by opening the Visual Studio solution created in the previous section and select any of the main projects (these are the ones labeled MyCompany.MyProduct...) in the Solution Explorer. Then navigate to Extensions > UiPath > Add Activities in the toolbar.
This will open a new Activity Creator window. The first screen gives you two options:
- Create: Build one or more activities from scratch.
- Import: Import a list of predefined activities that have been saved in a standard format.
For now, select Create.
Click the Add button and fill in each field as shown below. This will prepare the creator to build an activity named Addition. When ready, click the Edit button to add properties to the Addition activity.
This will open a new Define Properties window. Use the Add button to create 3 properties as shown below.
Ensure that the first two are inputs and the last is an output. These properties will represent two numbers and their sum.
Click OK on the Properties window and Finish on the activities window. You will then see some new files added to your projects.
Open the Addition.cs file that was just created and expand the
Protected Methods region within it to reveal the activity's
ExecuteAsync method. This is the method that gets called whenever the activity is run in UiPath Studio.
Notice that the two inputs created in step 4 (First Number and Second Number) as well as the one output (Sum) have already been added to this method. The final step is to bridge the gap between them by replacing the comment block with code that adds the two inputs and then sets the result to Sum. See below:
Within the Solution Explorer, right-click your Design project and select Publish. This option builds your projects, packages them together, and sends the package wherever you'd like.
In the next screen, enter the folder in which you'd like to save your activity package. It's a good idea to choose one of your package sources from UiPath Studio (you can find these at Settings > Manage Sources on the Studio homepage) so you can publish directly from Visual Studio into UiPath Studio.
Click Create Profile to continue.
On the next page, rename your package source to UiPath Packages (or whatever you'd like) and change the configuration to Debug. Then click Publish.
For more info on Debug vs Release configurations, see Package Metadata.
Your output will then show that all three projects have been built successfully and the resultant package published. You now have a working activity package!
Open UiPath Studio, navigate to the Package Manager, and add your activity set to workflow.
Notice that a new category has been added to the Activities pane.
That's all! Give your new activity a try!
Updated 10 days ago
Continue on to the next section to learn how to make the activity package your own by adding custom icons, links, tags, authors, and other metadata.