Library-authoring-guide
Part of Uipath rpa. Install the skill and your agent reads this page when it needs the depth.
Library Authoring Guide
How to produce a reusable library: a NuGet package whose public workflows surface as activities in every consuming project's panel. For finding and consuming libraries that already exist, see tenant-library-search-guide.md.
When to Build a Library
Good fit:
- Complex reusable actions shared by multiple processes — login flows, paginate-and-extract, shared validators, notification senders
- Standard practices the organization wants enforced once — logging wrappers, error handlers
- Interactions with a shared corporate system (ERP, CRM) that many automations touch
Not a fit:
- Process-specific logic — used once, belongs in the project
- Unstable code — frequent changes create versioning overhead for every consumer
- Tightly coupled workflows — only make sense inside one process
- Single activities — wrapping one
Clickas a library activity adds no value. Extract macro-actions (DownloadInvoices), not micro-primitives
Boundaries:
| Need | Go to |
|---|---|
| Start new projects from a standard baseline | Project templates — environment-setup.md § Template Selection |
| Share UI selectors across projects | UI Libraries — uia-policies-catalog.md § Object Repository as a Published UI Library |
| Reuse logic inside one project | Separate workflow file — environment-setup.md § Designing for Reuse |
Creating and Structuring
uip rpa init \
--name "<LIBRARY_NAME>" \
--location "<PARENT_DIR>" \
--template-id "LibraryProcessTemplate" \
--expression-language <VisualBasic|CSharp> \
--target-framework <Windows|Portable> \
--description "<DESCRIPTION>" \
--output json
<LIBRARY_NAME>: descriptive and scoped, dotted segments accepted —Company.Email.Utilities, notHelpers. The name becomes the package ID.- Default
--target-framework Portable(Cross-platform) for libraries. Cross-platform libraries (packed tolib/net8.0) install into both Cross-platform and Windows consumer projects; Windows libraries (lib/net8.0-windows7.0) install only into Windows projects. Choose Windows only when the library needs Windows-only activities or dependencies — every Windows-only pick shrinks the consumer base. <DESCRIPTION>(project.json→description) becomes the package description shown in the feed — write it for consumers.- The template scaffolds
NewActivity.xaml; replace it — delete the file and pointproject.json→mainat a real workflow, then add one workflow file per activity. - Library
project.jsondiffers from a process:designOptions.outputTypeis"Library", and there is noentryPoints(SKILL.md Rule 15) — do not add one.
Public vs private workflows
Every workflow file is public by default — packed as an activity. To keep a helper internal, add its filename to project.json:
"designOptions": {
"libraryOptions": {
"privateWorkflows": [
"ValidateEmailFormat.xaml"
]
}
}
Private workflows compile into the package and stay invocable from the library's own workflows, but no activity is generated for consumers.
Activity identity
- Activity name and class = workflow file name (
SendInvoiceNotification.xaml→ activitySendInvoiceNotification); a coded workflow's = its class name plusActivity(classCopyFolder→ activityCopyFolderActivity), its properties named as coded/operations-guide.md § Add a Workflow File states - Argument defaults reach consumers: a XAML workflow's root-element default (xaml/xaml-editing-catalog.md § Setting Default Values for Arguments) and a coded workflow's parameter default compile into the package and apply when a consumer leaves the argument unset.
packages inspectprints no defaults, so each argument's description states its default - Activity namespace = library name with dots and hyphens sanitized to underscores (
Company.Email.Utilities→ namespaceCompany_Email_Utilities); the package ID and assembly keep the dotted name. Read the real namespace fromuip rpa packages inspecton the packed.nupkg— never derive it - Property tooltip = the argument's description annotation in XAML:
sap2010:Annotation.AnnotationTexton thex:Property
Activity Layout — the sidecar file
Each public workflow can ship as a rich activity: custom display name, tooltip, color, SVG icon, and per-property display names, placeholders, input widgets, required flags, and category grouping. All of it is authored in a sidecar JSON next to the workflow — <WORKFLOW_NAME>.xaml.json:
{
"DisplayName": "Send Invoice Notification",
"Tooltip": "Sends an invoice notification email and returns a delivery summary",
"Color": "#1F8FFF",
"OriginalIconFileName": "SendInvoiceNotification.xaml.svg",
"Arguments": [
{
"Name": "in_RecipientEmail",
"DisplayName": "Recipient email",
"Category": "Input",
"Tooltip": "Email address that receives the notification",
"Placeholder": "someone@company.com",
"Widget": "TextComposer",
"IsRequired": true,
"IsPrincipal": true,
"ArgumentType": 0
},
{
"Name": "in_UrgentDelivery",
"DisplayName": "Urgent delivery",
"Category": "Options",
"Tooltip": "Send with high priority",
"Widget": "Toggle",
"IsRequired": false,
"IsPrincipal": false,
"ArgumentType": 0
}
]
}
Rules:
Arguments[].Namemust match the XAML argument name exactly — the sidecar decorates arguments, it does not declare them.- The sidecar wins over XAML annotations. Without a sidecar, the argument annotation is the tooltip and the file name is the display name; the sidecar overrides both and adds everything else.
- Icon: place an SVG next to the workflow as
<WORKFLOW_NAME>.xaml.svgand reference it inOriginalIconFileName.packembeds it as a package resource. Widgetis the property's input type (Studio: "Input type"). Valid values depend on the argument's type — omitWidgetfor the type's default editor:
| Argument type | Widget values |
|---|---|
String |
TextComposer (default), RichTextComposer, Dropdown, AutocompleteForExpression, RadioGroup |
Boolean / bool? |
Toggle (default), ConditionBuilder, NullableBoolean |
| Numeric | Number (default), Dropdown |
DateTime |
Datetime |
TimeSpan |
Timespan |
String[] |
StringArray |
Dictionary |
Dictionary |
DataSourceItems (string array of choices) applies only to Dropdown, RadioGroup, and AutocompleteForExpression.
5. Category groups properties in the activity's body, in sidecar argument order; IsPrincipal: true surfaces the property on the activity card, IsRequired: true marks it mandatory.
6. HelpLink is a valid sidecar field but stays design-time only — it does not ship in the compiled activity metadata.
7. ArgumentType is 0 for plain arguments.
pack compiles the sidecar into the activity metadata embedded in the library assembly — consumers see the layout in their Activities panel with no extra steps.
The Public-Workflow Contract — MANDATORY
Each public workflow is an API surface. Apply every rule:
- Name workflows verb-noun PascalCase, no spaces —
SendNotificationEmail.xaml,DownloadInvoices.xaml. The file name becomes the activity name in the consumer's panel. - Public arguments follow the Workflow Analyzer naming rules in force, as every workflow argument does (SKILL.md Common Rule 4c): PascalCase after whatever prefixes those rules require. Argument names become activity property names, which consumers' XAML attributes and coded calls use as written; give each public argument a display name in the layout sidecar (§ Activity Layout) and the property grid shows readable labels.
- Describe every public argument via its
sap2010:Annotation.AnnotationText— descriptions ship as property tooltips. For display names, placeholders, widgets, and grouping, add the layout sidecar (§ Activity Layout). - Leave no analyzer naming warning.
build/packreport each argument whose name breaks a naming rule in force (Argument <Name> does not respect the set pattern …,doesn't have datatable prefix); rename it before packing. A published library's existing public arguments keep their names and their warnings: renaming one is a breaking change (§ Versioning), and the compatible change, a new argument beside the old, follows the rules. - Return application handles. A workflow that opens or attaches to an app outputs the window/browser object, its card's Close set to
Neverso the window outlives the call; downstream public workflows accept it as an input argument instead of reopening, and the workflow that ends the application's work closes it with CloseAlwayson its card. - Post-authoring audit: before packing, re-check every public workflow against rules 1-3 — name form, argument naming, argument descriptions.
Error Contract
- Throw meaningful exceptions —
BusinessRuleExceptionfor input validation failures, with the offending value in the message. Let system exceptions propagate to the consumer. - Never swallow errors: no empty
Catchblocks, nooutboolean success flags in place of exceptions. A swallowed error returns control to a consumer whose target app is in an unknown state. - Never set
ContinueOnErrorinside a library — the consumer decides failure policy. - No hardcoded paths — accept paths as arguments, or build from
UiPath.Constants.Project.Locationfor files packed with the library. - No embedded config or secrets — read Orchestrator assets at the consumer level and pass them in as arguments; a credential by its asset's name (SKILL.md Common Rule 5a).
Versioning
projectVersion in project.json is the package version (override at pack time with --package-version). Follow SemVer:
| Bump | When | Consumer impact |
|---|---|---|
Patch x.x.1 |
Bug fix, no interface change | Safe drop-in |
Minor x.1.x |
New workflow or new optional argument, backward compatible | Safe upgrade |
Major 1.x.x |
Renamed/removed workflow or argument, changed behavior | Code changes required |
- Renaming a public workflow or argument is a breaking change — major bump. To change an argument compatibly, add a new one and keep the old.
- Never delete published versions from the feed — consumers pin them.
libraries deleteis for mistaken uploads only. - Consumers pin exact versions in production.
Pack & Publish
uip rpa pack "<PROJECT_DIR>" "<OUTPUT_DIR>" --output json
uip rpa publish "<OUTPUT_DIR>/<LIBRARY_NAME>.<VERSION>.nupkg" --output json
publishreads the package's type and sends a library to the tenant Libraries feed (Data.Feed:Orchestrator Tenant Libraries Feed), not the processes feed a process goes to. Other destinations, refusals and the duplicate-version error: cli-reference.md § Pack & Publish to Orchestrator.<OUTPUT_DIR>must be OUTSIDE the project directory tree —packrefuses an output path inside the project. Use a sibling directory (e.g.dist/).- Verify the publish:
uip or libraries list --search "<LIBRARY_NAME>" --output json
Returns the library with Key = <PackageId>:<Version> and ProjectType: "ProcessLibrary".
Consumption Loop
- Discover existing libraries before building new ones — tenant-library-search-guide.md (SKILL.md Rule 9).
- Install into the consumer as a dependency — SKILL.md § Resolving Packages & Activity Docs. The install records the dependency in the consumer's
project.json; the library's activities become available. - Build-time resolution: signed in,
buildandpackrestore the library from the tenant's libraries feeds, as the install does; no extra NuGet source is needed. - Author against the library in consumer XAML. Once the library is installed,
activities findreturns its public workflows andactivities get-default-xamlreturns each one's element with its arguments as properties, without their types or directions — read those from the package itself:
uip or libraries download "<PackageId>:<Version>" --destination "<LOCAL_DIR>/<LIBRARY_NAME>.<VERSION>.nupkg" --output json
uip rpa packages inspect --nupkg-path "<LOCAL_DIR>/<LIBRARY_NAME>.<VERSION>.nupkg" --output json
Declare the namespace and use each public workflow as an element — property names = the library's argument names:
<Activity ... xmlns:lib="clr-namespace:<SANITIZED_NAMESPACE>;assembly=<LIBRARY_NAME>">
<lib:SendInvoiceNotification in_RecipientEmail="..." in_InvoiceId="..." />
<SANITIZED_NAMESPACE> is the underscore form from § Activity identity. Bind non-literal properties per the project's expression language rules (xaml/xaml-basics-and-rules.md).
- Stale design session after the dependency becomes resolvable:
buildcompiles the consumer butvalidatekeeps failing withCannot create unknown typefor the library activity. Runuip rpa project close --project-dir "<CONSUMER_PROJECT_DIR>"and re-runvalidate; the next command reloads the project. - Same version repacked: the package cache keeps the first package under an id and version and ignores a repack, so bump the library version whenever a consumer must see a change.
- Dependency floor: the consumer's version of each package the library depends on is at least the library's. A consumer pinned lower validates and builds with only a warning,
Detected package downgrade: <PACKAGE_ID> from <LIBRARY_VERSION> to <CONSUMER_VERSION>, then fails at run time loading the library's assembly version (Could not load file or assembly '<PACKAGE_ID>, Version=…'). Treat that warning as an error: raise the consumer's dependency to the version it names.
Library Patterns
| Pattern | Shape | Example |
|---|---|---|
| Wrapper | Bundle related operations into one higher-level activity | OpenExcelAndReadSheet instead of Open Workbook + Read Range |
| Connector | One library per corporate system — single source of auth, selectors, business rules | CompanyERP.Library owns all ERP interactions |
| Framework | Scaffolding consumers extend (REFramework-style) | State machine with extension points |
| Data access | Centralize database/API access behind typed activities | GetCustomerById returns a row from any backend |
Pitfalls
- Never name a library project
lib— collides with the NuGet package folder layout; consumers fail to compile. - A workflow file and one of its arguments must not share the same name — publishing crashes on the name collision.
- Never set
ImplementationVersionon the XAMLActivityBuilder— a framework bug silently drops the library's argument mappings.