Development Your First Hello World Custom Rule - rpapub/WatchfulAnvil GitHub Wiki
Caution
Content needs proof-reading.
Welcome to the final step of the Getting Started guide! This page shows you how to generate your own baseline project using the built-in script β and how to safely revert your experiments to start over if needed.
You will:
- Scaffold a brand-new custom Workflow Analyzer rules project with your organization name and rule prefix.
- See a functional "Hello World" rule inside UiPath Studio.
- Understand the layout and structure of your generated project.
- Learn how to clean up and start fresh, as often as you need.
Run the script provided in the repo:
.\tools\New-RulesProject.ps1
- Organization Name: Used in your projectβs namespace and folder name.
-
Rule ID Prefix: A short (2β5 uppercase letters) prefix used in your rule IDs like
HWR-0001
.
Enter your organization name [ACME]:
Enter the rule ID prefix (2-5 uppercase letters) [HWR]:
The script creates two projects and updates the solution file:
WatchfulAnvil/
βββ src/
β βββ ACME.HelloWorld.WorkflowAnalyzerRules/
βββ tests/
β βββ ACME.HelloWorld.Tests/
βββ WatchfulAnvil.sln
-
SampleRule.cs
: Your "Hello World" custom rule -
RegisterAnalyzerConfiguration.cs
: Entry point that registers your rule -
*.csproj
: Project files targeting multiple .NET versions - A test project (xUnit + Moq) that builds in CI
Open SampleRule.cs
under Rules/
.
You can easily:
- Change the rule ID or description
- Tweak the rule's DefaultErrorLevel to TraceLevel.Error or TraceLevel.Warning or TraceLevel.Info
- Edit the RecommendationMessage or DocumentationLink
Note
More substantial editing is not in scope of this Getting Started guide, and will be covered in the future. If your custom rule successfully shows up in UiPath Studio, you can consider it a success for now.
- Open the solution (
WatchfulAnvil.sln
) in Visual Studio. - Build the solution using
Build β Build Solution
(orCtrl+Shift+B
).The individual images of this sequence can be found here. Use the browser's back button to return to this page.
- Check that DLLs were created for:
-
net461
(legacy) -
net6.0
(Windows) -
net8.0
(Windows)
-
- Copy the correct DLL into the corresponding Studio
Rules
folder (see this page for reference, and use the browser's the back button to return to this page.).
- In case of an error similar to "
The process cannot access the file ... because it is being used by another process
", UiPath Studio is open and must be closed before copying the DLL. If anAccess Denied
error is returned, then the user does not have the sufficient permissions to write to the target folder and a PowerShell with elevated Admin permissions is required.
Important
The screenshot shows a UiPath Studio instelled in System Mode. That is why the Rules folder is located in a path that requires elevated permissions.
- Open a project in UiPath Studio (both Legacy and Windows).
- Run Workflow Analyzer.
- Confirm that your rule (
HWR-SAMPLE-001
) appears.
You can generate and regenerate projects freely. To reset:
dotnet sln WatchfulAnvil.sln remove src\ACME.HelloWorld.WorkflowAnalyzerRules\ACME.HelloWorld.WorkflowAnalyzerRules.csproj
dotnet sln WatchfulAnvil.sln remove tests\ACME.HelloWorld.Tests\ACME.HelloWorld.Tests.csproj
Remove-Item -Recurse -Force .\src\ACME.HelloWorld.WorkflowAnalyzerRules
Remove-Item -Recurse -Force .\tests\ACME.HelloWorld.Tests
Now you can rerun .\tools\New-RulesProject.ps1
anytime to start fresh with a clean, functional baseline.
β‘οΈ Continue with: Plan New Rules