Studio 中的项目依赖项是指链接到特定项目的包,其中包含了默认活动或自定义活动。依赖项与上下文有关,并且需要考虑每个项目的定义,包括变量、输入/输出参数以及项目使用的活动。因此,仅当项目定义中至少有一个引用时,才会设置依赖项。
Studio 中可用的所有项目模板都带有其自己的默认依赖项包。
在 StudioX 中,所有的项目都使用下列默认包:UiPath.System.Activities
、UiPath.ComplexScenarios.Activities
、UiPath.Excel.Activities
、UiPath.Mail.Activities
、UiPath.Presentations.Activities
、UiPath.UIAutomation.Activities
和 UiPath.Word.Activities
。
如果需要添加更多包,可单击“管理包”按钮并进行安装。安装的依赖项仅可供当前项目使用,各个项目的依赖项列表则可在 project.json
文件中查看。
“项目”面板中显示自动化项目中安装的活动包,以及它们的子依赖项、运行时规则、已请求及已解决的版本。项目兼容性将显示在“依赖项”节点中。

将光标悬停在依赖项上可查看已请求和已解决的版本。“管理”、“修复”或“删除依赖项”等上下文操作仅适用于依赖项,不适用于其子包。未解决的依赖项在树中用灰色标记,未找到的依赖项用红色标记,而已解决和完全匹配的依赖项则使用阴影和深蓝色标记。
添加和更新依赖项
Whenever new versions are available for the current project dependencies, the Manage Packages button from the ribbon gets an update icon .
- 要管理项目中的依赖项,只需右键单击“项目”面板中的“依赖项”类别,然后单击“管理”。这将打开“管理包”窗口,其中包含“项目依赖项”类别。
图标显示当前安装的包。

- 系统将显示默认依赖项以及当前链接到项目的版本。要更新软件包,只需单击更新图标
旁边的可用版本编号。
图标显示在包的旁边,表示依赖项已做好安装准备。
- 只有在单击“保存”之后,才会在项目中安装依赖项。同时,还会在属于项目的
project.json
文件中更新依赖项的版本。
To add dependencies to a project, simply search and install them as you would any activity package. Please note that the available packages differ depend on the project compatibility. For more information, check the Manage Packages page.
删除依赖项
- 要删除项目依赖项,请右键单击“项目”面板中的依赖项,然后选择“删除依赖项”。依赖项即从“项目”面板和
project.json
文件中删除。
或者,您可以转到“管理程序包”>“项目依赖项”,选择要删除的依赖项,然后单击“卸载”。 - 要删除项目中所有未使用的依赖项,请在 Studio 功能区中选择“删除未使用项”>“依赖项”,或使用“Ctrl + Shift + R”键盘快捷键。当前项目中没有引用的所有已安装程序包都将从“项目”面板和
project.json
文件中删除。
修复依赖项
如果在 Studio 中打开的工作流引用了某些包,而这些包的版本在当前 Studio 订阅源中不可用,则表示依赖项在“项目”面板中标记为断开,而且“输出”面板中将提供详细信息。
Studio 允许批量或单独修复所有依赖项。要修复所有损坏的依赖项,请右击“项目”面板中的“依赖项”节点,然后单击“修复依赖项”。
右击已损坏的依赖项,然后选择“解决依赖项”以单独修复该依赖项。此外,也可选择“管理”以打开“管理包”窗口,再更新包。
NuGet resolves broken dependencies by applying the Lowest Applicable Version runtime rule, meaning that it searches for the first applicable package version, higher than the one previously set.

备注:
缺失或无效的活动在“设计器”面板中标记,而错误横幅则提供有关工作流及其无法解析的依赖项的其他信息。
设置依赖项规则
活动包提供有多个版本,因此在使用”管理包”安装或更新它们时,您可以为它们分别设置依赖项运行时规则。

“运行时规则”指定要在运行时安装的包版本。它有两个可用的选项。
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 Project 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 Project panel, under Dependencies by the sign next to the package version.
When executing an automation project from Studio, the Robot downloads the specified or indicated package version it needs to execute the project, in accordance to the previously set runtime rules for each project. If the dependency used during execution has a Strict runtime rule and the exact package version was not found, an error is thrown. For more information on setting runtime rules for project dependencies check the Managing Dependencies page.
解决依赖项冲突
活动包的安装考虑了以前为上述包设置的依赖项运行时规则,但是当项目自动化时,版本之间可能会发生一些冲突。自动化项目和它包含的库都可能有相同的活动包,但版本和运行时规则不同。在设计时,NuGet 通过选择最高级别的依赖项(也就是最接近层次结构中的项目的依赖项)来解决这些冲突。
下面介绍了可能出现的冲突的解决方法:

该项目包含 1.0 版活动包。库在项目中引用并使用相同的包,但具有更高的版本。在运行时使用最高级别依赖项 v1.0。系统发出警告,并检测到降级问题。
The resolution of this scenario is applicable regardless of the runtime rule (Strict or Lowest Applicable Version
) previously set for the activities packages.

- 如果选择“是”,则项目中引用的活动包将升级为库中使用的版本。
- 如果选择“否”,则“管理包”窗口打开将显示“项目依赖项”列表。

The project contains an activities package with the version 2.0. The library uses the same pack, but with a lower version and the Strict runtime rule. The top level dependency used in this case is v2.0 and a warning is given when the package is installed in the project.

The project contains an activities package with the version 2.0. The library uses the same pack, but with a lower version and the Lowest Applicable Version runtime rule. The top level dependency used in this case is v2.0 and a warning is given when the package is installed in the project.

The project references a library with an activities package version 1.0 and Strict runtime rule. The project references another library, but with an activities package version 2.0. The top level dependency in this case is the pack with v2.0, since it has the highest version. A warning is given when the activities package is installed.

In this conflict the project references two libraries, which in turn have Strict dependencies referenced among them. This scenario isn't supported. For detailed information, check the Dependency Resolution page.
如果包引用自身,那么将发生的冲突类型是依赖项循环。如果将项目命名为 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 Project 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.
Processes containing dependencies and that were built with Studio versions prior to v2018.3 continue to execute with Robot v2018.3. The runtime rule for such projects is set to Lowest Applicable Version .
Projects created with versions prior to v2018.3 that were never published don't have dependencies listed in the project.json
file. When opening such projects, an alert in the Output panel notifies you of missing dependencies. UiPath packages delivered locally with Studio are added as dependencies with the Strict runtime rule. The latest version of such packages is automatically set.
如果这类项目包含非 Studio 本地随附的包,我们建议:
- 使用创建此项目的 Studio 版本发布此项目,以此在
project.json
文件中添加依赖项,帮助您完成迁移流程; - Manually installing the missing package from the Manage Packages window, after setting up the required feed;
- Using the Project Dependencies Mass Update tool to add the missing dependency to a bulk of projects.
备注:
无法保存包含无效活动的工作流。安装所需的依赖项,然后保存项目。
活动包 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"
。保存文件。 - 使用 Studio v2018.3 或更高版本打开
.xaml
文件,这样就会执行迁移了。弃用的活动包将被替换为新版本的活动包,如“项目”面板的“依赖项”部分所示。
重要
在某些情况下,包含包
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 之前的版本升级,这两个活动包仍会保留在“本地”订阅源中。
大约一年前更新