UiPath Documentation
studio
2022.4
false
Studio 用户指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

关于库

A library is a project which contains one or more workflows that can be reused as activities in other projects. Libraries are saved as NUPKG files when published and can be installed as dependencies from the Package Manager.

For example, you could create a library that collects data from an Excel spreadsheet and appends it to another, as explained in the Creating a Basic Library page. Next, the library can be packaged and used in other processes as an activity.

创建库

  1. 转到“Studio 后台视图”>“开始”>“库”。这将打开新建空白库窗口。

  2. 填写库的名称并为库选择一个位置。默认位置为 C:\Users\<current_user>\Documents\UiPath。添加描述,选择项目兼容性和语言,然后选择“创建”。系统将创建新库并将其保存在本地计算机上。

    备注:
    • 库名称不能超过 128 个字符,描述不能超过 500 个字符。
    • 不要使用 lib 作为库名称,因为这将导致安装库的项目中出现编译错误。
  3. “项目”面板显示一个树视图,其中包括“项目”文件夹、“依赖项”以及包含实际工作流的 NewActivity.xaml

    在将库作为依赖项安装的项目中,库中的每个工作流文件都可作为活动提供。如果要将某个文件设为私有,请右键单击该文件,然后选择“设为私有”。在本例中,该文件包含在库包中,但是在“活动”面板中不能作为可重用组件使用。

    备注:

    默认情况下,新库可以使用的依赖项与空白新项目可以使用的依赖项相同,即 UiPath.Excel.ActivitiesUiPath.Mail.ActivitiesUiPath.System.ActivitiesUiPath.UIAutomation.Activities(“最低适用版本”规则有效)。

要添加工具提示并帮助链接到活动,请在“项目”面板中右键单击工作流文件,然后选择“属性”。当您在安装了库的项目中,将鼠标悬停在“活动”和“设计器”面板中的活动上时,则可以看到该工具提示。当您在“设计器”面板中选择活动并按 F1 时,“帮助链接”将打开。

Arguments you define in the library become activity properties in the projects where the library is installed as a dependency. Arguments that are marked as required are available in the body of the activity in the Designer panel. Annotations you add to an argument in the library are displayed as a tooltip for the property in the resulting activity's Properties panel. For more information about arguments, see Arguments Panel.

备注:
  • 就库而言,建议使用 Nothing(而非 "")将 null 值分配给变量。如此一来,在将打包的库作为依赖项用于项目中时,便能避免发生任何不一致的情况。
  • 不支持 System.Activities.ActivityBuilder 对象的“实现版本”属性。为该属性设置值将导致参数无法保存。当您选择“设计”面板的空白区域,该对象显示在“属性”面板中。

调整库设置

要配置库项目的设置,请单击“项目”面板中的“设置”文档图像,打开“项目设置”窗口。

“常规”选项卡中提供以下选项:

  • 名称 - 编辑项目的名称。

  • 描述 - 编辑项目的描述。

  • Automation Hub URL - URL of an Automation Hub idea linked to the project. For more information, see Linking a Project to an Idea in Automation Hub.

  • 项目图标 -(可选)定义项目的自定义图标。您可以浏览并选择一个文件,或者为大小至多 1MB 的 icojpegjpgpng 文件输入路径或公共 URL。

    After the project is published, the icon is displayed next to the package in the Manage Packages window in Studio.

  • 包含源 - 设为“是”以包含库包中的所有 .xaml 源,包括先前设为私有的工作流。对于 Windows - 旧版库,这些文件保存在生成的程序集文件和 .nupkg 文件的 lib\net45 文件夹中。对于 Windows 和跨平台库,文件将保存在 .nupkg 文件的 content 文件夹中。

  • 编译活动表达式 - 设置为“是”以编译所有活动表达式并将其与库打包。这可缩短执行时间。可用于 Windows - 仅旧版库。

  • 准备运行 - 设置为“是”以优化生成的程序集,以便在运行时更快地进行 JIT 编译。可用于 Windows - 仅旧版库。

  • Modern Design Experience - set to Yes to enable a modern experience of working with UI Automation, including new and improved activities, recorders, and wizards, as well as the Object Repository.

发布库

Publishing libraries is similar to publishing processes. For more information, see About Publishing Automation Projects.

发布库时的限制

发布库时,请考虑以下限制:

  • 由于 NuGet 的限制:
    • 您无法使用 Windows 环境路径变量将库发布到包含用户受限的子文件夹所在的位置。
    • 已发布库的发行说明仅在 Orchestrator 中可见。
  • 如果库中 .xaml 文件的名称中包含特殊字符,则该库可能无法成功发布。
  • 如果库包含名称相同的 .xaml 文件和参数,则无法发布该库。
  • 如果库项目包含“调用工作流文件”活动并选择“隔离”选项,则无法发布具有 Windows - 旧版兼容性的项目。 尝试发布时,“输出”面板中会显示一条错误消息。此限制不适用于使用 Windows 或跨平台兼容性的库。
  • 在使用“调用工作流文件”活动时,请确保所调用的文件与库项目位于同一个文件夹中。
  • 库不支持“启动工作流交互式”活动。
  • 不支持在库中使用“调用工作流文件”来引用库本身。
  • If a library contains an activity that accepts a file path as input, when the component is used in a project, paths that include environment variables are interpreted as paths relative to the library folder. As a workaround, use either the Environment.GetEnvironmentVariable method or a Get Environment Folder activity to retrieve the folder path, and then use the output to construct an absolute path to pass to the reusable component.
  • 如果将放置在库文件夹中的工作流文件用作项目中的命名空间,则在项目中更改文件夹名称、重新发布和安装更新的库会导致未知活动。

向自动化项目中添加可重用组件

  1. 打开现有项目,或创建一个新项目。
  2. 在“所有包”类别下,选择保存库的订阅源并安装包。
  3. 选择“确定”,然后包将被添加到项目定义中。
  4. 该活动位于“活动”面板中的自定义类别中。

在项目中安装库的注意事项

  • Libraries can only be installed in projects that have the same compatibility.

  • 如果跨平台库包含具有用户界面自动化活动的工作流,则在跨平台项目中添加生成的活动会导致执行项目时出现验证错误。

  • 当您运行的项目包含自定义活动的项目时,可能会发生错误,这些自定义活动来自在 2019.10.1 之前的 Studio 版本中创建并通过 Studio 2019.10.1 或更高版本发布的库中。在这种情况下,您必须重新创建并重新发布库。

  • 在库项目中,当使用“导入工作流”来添加包含库的工作流时,不会导入库中引用的依赖项。

  • 将同一自定义库的两个版本导入项目时,仅包含在第二个库中的额外自定义活动在“活动”面板中不可见,除非您删除第一个导入的库。

  • 使用库中的自定义活动时,当活动添加到工作流中时,为参数定义的任何默认值都会自动预填充到活动的“属性”面板中。如果从工作流中的“属性”字段清除该值,运行时不会使用对应的默认值。在这种情况下,会明确传递一个空值。

    相反,使用“调用工作流”活动时,在“导入参数”面板中将输入保留为空白时,运行时会使用被调用工作流中定义的默认值。

  • 创建库
  • 调整库设置
  • 发布库
  • 发布库时的限制
  • 向自动化项目中添加可重用组件

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新