- 入门指南
- 设置和配置
- 自动化项目
- 依赖项
- 工作流类型
- 控制流程
- 文件比较
- 自动化最佳实践
- 源代码控件集成
- 调试
- 日志记录
- 诊断工具
- 工作流分析器
- 变量
- 参数
- 导入的命名空间
- 编码自动化
- 基于触发器的 Attended 自动化
- 对象存储库
- ScreenScrapeJavaSupport 工具
- 扩展程序
- Studio 测试
- 故障排除
管理依赖项
在 Studio 中管理项目依赖项,包括添加、更新和移除链接到自动化项目的活动包。
Studio 中的项目依赖项是指链接到特定项目的包。这些包中包含默认或自定义活动。
依赖项与上下文相关,并且考虑到:
- 项目使用的活动
- 项目变量
- 输入和输出参数
仅当项目定义中至少存在一个引用时,才会设置依赖项。
默认依赖项和自定义依赖项
项目的默认依赖项因项目类型、兼容性或用于创建项目的模板而异。
如果需要添加更多包,可单击“管理包”按钮并进行安装。安装的依赖项仅可供当前项目使用,各个项目的依赖项列表则可在 project.json 文件中查看。
The Explorer panel displays the activities packages installed in the automation project, together with their sub dependencies, runtime rules, requested, and resolved versions. The project compatibility is displayed in the Dependencies node.
将光标悬停在依赖项上可查看已请求和已解决的版本。“管理”、“修复”或“删除依赖项”等上下文操作仅适用于依赖项,不适用于其子包。
树中依赖项的状态以不同颜色表示:
- 红色 - 未找到依赖项。
- 橙色 - 未找到子包。
- 灰色 - 未解决依赖项。
- 淡蓝色 - 已解析的版本高于请求的版本。
- 深蓝色 - 请求的版本与已解决的版本之间完全匹配。
添加和更新依赖项
每当有新版本可用于当前项目依赖项时,功能区中的“管理包”按钮将显示更新图标
。
-
To manage dependencies in a project, open the context menu for the Dependencies category in the Explorer panel, and then select Manage. This opens the Manage Packages window, with the Project Dependencies category. The
icon shows which packages are currently installed. -
Default dependencies are displayed, together with the versions that are currently linked to the project. To update a package, select the update icon
, next to the available version number. The
icon is shown next to the package, meaning that dependencies are ready to be installed. -
只有在选择“保存”之后,才会在项目中安装依赖项。同时,还会在属于项目的
project.json文件中更新依赖项的版本。
结果
系统会将所选依赖项添加到项目或在项目中更新。在 project.json 文件中更新包版本。
删除依赖项
- To remove a project dependency, right-click the dependency in the Explorer panel, and then select Remove Dependency. The dependency is removed from the Explorer panel and
project.jsonfile. Alternatively, you can go to Manage Packages > Project Dependencies, select the dependency to remove, and then click Uninstall. - To remove all unused dependencies in the project, select Remove Unused > Dependencies in the Studio ribbon, or use the Ctrl + Shift + R keyboard shortcut. All the installed packages that have no references in the current project are removed from the Explorer panel and
project.jsonfile.
修复依赖项
If a workflow opened in Studio has references to packages with versions that aren’t available in current Studio feeds, said dependencies are marked as broken in the Explorer panel and details are made available in the Output panel.
修复依赖项
Studio allows for all dependencies to be repaired in bulk or individually. To repair all broken dependencies, right-click on the Dependency node in the Explorer panel, and click on Repair Dependencies.
右击已损坏的依赖项,然后选择“解决依赖项”以单独修复该依赖项。此外,也可选择“管理”以打开“管理包”窗口,再更新包。
Nuget 通过应用“最低适用版本”
运行时规则来解决中断的依赖项,这表示它将搜索第一个适用的包版本(高于以前设置的版本)。
缺失或无效的活动在“设计器”面板中标记,而错误横幅则提供有关工作流及其无法解析的依赖项的其他信息。
设置依赖项规则
活动包提供有多个版本,因此在使用”管理包”安装或更新它们时,您可以为它们分别设置依赖项运行时规则。
“运行时规则”指定要在运行时安装的包版本。它有两个可用的选项。
The Strict runtime rule is the default state for dependencies added upon process creation, and for activities packages installed from the Manage Packages window. It means that only the specified version of the package is used at runtime to execute the parent process. The Strict rule is marked in the Explorer panel, under Dependencies by the
sign next to the package version.
The Lowest Applicable Version runtime rule means that if the target package isn’t found, the next higher version is searched in order to resolve dependencies. The Lowest Applicable Version rule is marked in the Explorer panel, under Dependencies by the
sign next to the package version.
使用依赖项规则执行
从 Studio 执行自动化项目时,机器人将根据先前为每个项目设置的 Runtime 规则,下载执行该项目而需要的指定包版本。如果执行过程中使用的依赖项具有“严格”运行时规则,并且没有找到确切的包版本,则会抛出错误。有关设置项目依赖项的 Runtime 规则的详细信息,请查看管理依赖项页面。
解决依赖项冲突
活动包的安装会考虑先前设置的依赖项运行时规则。但是,自动化项目时,版本之间可能会发生冲突。
自动化项目及其库可能包含相同的活动包,但具有不同的版本和运行时规则。在设计时,NuGet 通过选择最高级别依赖项(层次结构中最靠近项目的依赖项)来解决此类冲突。
下面介绍了可能出现的冲突的解决方法:
该项目包含 1.0 版活动包。库在项目中引用并使用相同的包,但具有更高的版本。在运行时使用最高级别依赖项 v1.0。系统发出警告,并检测到降级问题。
无论以前为活动包设置了何种运行时规则(“严格”
或“最低适用版本”
),此场景的解决方案均适用。
-
如果选择“是”,则项目中引用的活动包将升级为库中使用的版本。
-
如果选择“否”,则“管理包”窗口打开将显示“项目依赖项”列表。
项目包含版本为 2.0 的活动包。库使用相同的包,但版本较低,并且
运行时规则。在这种情况下,使用的最高级别依赖项是 v2.0,在项目中安装包时会发出警告。
项目包含版本为 2.0 的活动包。库使用相同的包,但版本和最低适用版本较低
运行时规则。在这种情况下,使用的最高级别依赖项是 v2.0,在项目中安装包时会发出警告。
项目引用活动包版本为 1.0 且为“严格”的库
运行时规则。项目引用另一个库,但其活动包版本为 2.0。在这种情况下,最高级别依赖项是版本为 2.0 的包,因其版本最高。安装活动包时会发出警告。
在此冲突中,项目引用两个库,而两个库之间又引用了“严格”
依赖项。不支持此方案。如需了解详情,请查看“依赖项解决方法”页面。
如果包引用自身,那么将发生的冲突类型是依赖项循环。如果将项目命名为 UiPath,Studio 将检测到依赖项冲突。这是因为 UiPath 包已经存在,并且依赖于 UiPath.UIAutomation.Activities。在命名项目时,建议您避免使用要作为依赖项添加的现有包的名称。
在下面的情况下,会发生相同的依赖项循环:您打开 .xaml 文件时是从名为 UiPath 的文件夹,或者是从名为从您要添加为依赖项的任何现有包,但该文件夹中没有 project.json。当您打开一个没有关联 project.json 文件的 .xaml 文件时,Studio 会创建一个 project.json 文件,并用父文件夹的名称来填充 "name" 标签。
打开使用先前版本创建的项目
不支持直接在 Studio v2020.4 或更高版本中打开使用 Studio v2016.2 创建的项目。请先使用 Studio v2018.4 打开项目,再使用 v2020.4 打开。
当打开包含或不含依赖项的项目时(使用 v2018.3 之前的版本设计,v2016.2 除外),Studio 会询问您是否应该执行自动迁移,以便尝试检索缺少的依赖项或添加默认依赖项。
Upon confirmation, Studio attempts to retrieve missing dependencies and sets the Strict
runtime rule for the packages that it finds. When using the Repair Dependency option in the Explorer panel, Studio attempts to install the next best package version. If the package version is not found, alerts are shown in the Output panel and you should check the configured feeds in the Manage Packages window.
旧项目的依赖项
包含依赖项的流程以及使用 v2018.3 之前的 Studio 版本构建的流程将继续在 Robot v2018.3 中执行。此类项目的运行时规则设置为“最低适用版本”
。
对于使用 v2018.3 之前的版本创建的未曾发布的项目, project.json文件中不会列出其依赖项。打开此类项目时, “输出”面板中的警示会通知您缺少依赖项。Studio 本地随附的 UiPath 包将添加为依赖项,并且添加了“严格”属性
运行时规则。系统会自动设置此类包的最新版本。
如果这类项目包含非 Studio 本地随附的包,我们建议:
- 使用创建此项目的 Studio 版本发布此项目,以此在
project.json文件中添加依赖项,帮助您完成迁移流程; - 设置所需的订阅源后,从“管理包”窗口中手动安装缺失的包;
- 使用“项目依赖项批量更新”工具将缺失的依赖项添加到大量项目。
备注:
无法保存包含无效活动的工作流。安装所需的依赖项,然后保存项目。
活动包 UiPath.V7.Activities、UiPath.Platform.Activities 和 UiPath.Framework.Activities 已被弃用。当打开包含 UiPath.Platform.Activities 和 UiPath.Framework.Activities 包的项目时,Studio v2018.3 或更高版本将尝试执行自动迁移,将旧版本的活动替换为新版本。
如果工作流包含了属于 UiPath.V7.Activities 包的活动,那么工作流无法迁移。
对于某些未自动执行迁移的情况,有一种变通方法。
- 使用 Notepad++ 打开
project.json文件。 - 删除
"schemaVersion": "3.2"参数。 - 将
"studioVersion"替换为"toolVersion"。 - 将
"toolVersion"值从"18.3.xxx"更改为先前版本。例如,将值从"18.3.0.958"更改为"18.2.958"。保存文件。 - Open the
.xamlfile with Studio v2018.3 or above for the migration to be performed. The deprecated activities packages are replaced with new ones, as illustrated in the Dependencies section of the Explorer panel.备注:在某些情况下,包含包
UiPath.Platform.Activities和UiPath.Framework.Activities的.xaml文件无法自动迁移,并且变通方法也不适用。对于这些情况,建议在 Studiov2018.2 或更低版本中打开项目,然后将属于上述包的活动替换为UiPath.Core.Activities包中包含的活动。对于包含UiPath.V7.Activities包中的活动的工作流,也可以这样做。
自 Studio v2018.4.1 起,UiPathStudio.msi 安装程序中将不会再打包 Microsoft.Activities v.1.0.1 和 Microsoft.Activities.Extensions v2.0.6.9。
如果在迁移以这些包作为依赖项的项目时需要进行修复,请从“官方”订阅源或本地订阅源安装这两个包。在执行以 v2018.4.1 之前的版本创建的这类项目之前,请确保上述包位于机器人可访问的订阅源中。
若从 v2018.4.1 之前的版本升级,这两个活动包仍会保留在“本地”订阅源中。