- 概述
- 自定义活动
- 将活动迁移到 .NET 6
- 发行说明
- 构建工作流分析器规则
- 构建活动项目设置
- 创建自定义向导
- 按范围划分活动的优先级
- UiPath.Activities.Api.Base
- UiPath.Studio.Activities.Api
- UiPath.Studio.Activities.Api.Activities
- UiPath.Studio.Activities.Api.BusyService
- UiPath.Studio.Activities.Api.ExpressionEditor
- UiPath.Studio.Activities.Api.Expressions
- UiPath.Studio.Activities.Api.Licensing
- UiPath.Studio.Activities.Api.Mocking
- UiPath.Studio.Activities.Api.ObjectLibrary
- UiPath.Studio.Activities.Api.PackageBindings
- UiPath.Studio.Activities.Api.ProjectProperties
- UiPath.Studio.Activities.Api.ScopedActivities
- UiPath.Studio.Activities.Api.Settings
- UiPath.Studio.Activities.Api.Wizards
- UiPath.Studio.Activities.Api.Workflow
- UiPath.Studio.Api.Controls
- UiPath.Studio.Api.Telemetry
- UiPath.Studio.Api.Theme
- Robot JavaScript SDK
- 触发器 SDK
- 智能体 SDK
开发者指南
本页概述了如何将自定义 .NET Framework 活动迁移到 .NET 6,以便在从 Studio 2021.10.6 开始具有 Windows 兼容性的项目中使用。
我们将使用 “ 使用代码创建活动(旧版)” 页面上记录的示例 MathSquareOfSum 活动作为迁移到面向 Windows 的 .NET 6 的示例,同时还保持与 .NET Framework 的 Windows - 旧版项目的兼容性。
第 1 步:将项目迁移到新的 SDK 样式格式,并将 net6.0-windows 目标
必须将使用 .NET Framework 项目格式的项目迁移到新的 SDK 样式格式。有关更多信息,请参阅Microsoft 文档。必须在.csproj文件中声明包引用文件,而不是packages.config 。
- 在“解决方案资源管理器”中,右键单击项目,然后选择“卸载项目” 。
- 复制引用并清除
.csproj文件中的所有内容。 - 手动将
.csproj文件更新为新格式。 - 添加目标框架net6.0-windows 。
- 仅通过添加条件将原始引用标记为net461 。
- 新增包含net6.0-windows条件的参考文献部分。您必须为 .NET 声明以下 WWF 依赖项:UiPath.Workflow.Runtime、UiPath.Workflow、System.Activities.Core.Presentation 和 System.Activities.Metadata。确保所有依赖项都支持 .NET。您可能需要查找较新的包版本或替换包。
- 在“解决方案资源管理器”中,右键单击项目,然后选择“重新加载项目” 。
该文件应如下所示。
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
<PropertyGroup>
<TargetFrameworks>net461;net6.0-windows</TargetFrameworks>
<AssemblyName>MathSquareOfSum</AssemblyName>
<RootNamespace>MathSquareOfSum</RootNamespace>
<UseWpf>true</UseWpf>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Activities" />
<Reference Include="System.Activities.Core.Presentation" />
<Reference Include="System.Activities.Presentation" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
<PackageReference Include="UiPath.Workflow.Runtime" Version="6.0.0-20220401-03" PrivateAssets="All" />
<PackageReference Include="UiPath.Workflow" Version="6.0.0-20220401-03" PrivateAssets="All" />
<PackageReference Include="System.Activities.Core.Presentation" Version="6.0.0-20220318.2" PrivateAssets="All" />
<PackageReference Include="System.Activities.Metadata" Version="6.0.0-20220318.2" PrivateAssets="All" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
<PropertyGroup>
<TargetFrameworks>net461;net6.0-windows</TargetFrameworks>
<AssemblyName>MathSquareOfSum</AssemblyName>
<RootNamespace>MathSquareOfSum</RootNamespace>
<UseWpf>true</UseWpf>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Activities" />
<Reference Include="System.Activities.Core.Presentation" />
<Reference Include="System.Activities.Presentation" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
<PackageReference Include="UiPath.Workflow.Runtime" Version="6.0.0-20220401-03" PrivateAssets="All" />
<PackageReference Include="UiPath.Workflow" Version="6.0.0-20220401-03" PrivateAssets="All" />
<PackageReference Include="System.Activities.Core.Presentation" Version="6.0.0-20220318.2" PrivateAssets="All" />
<PackageReference Include="System.Activities.Metadata" Version="6.0.0-20220318.2" PrivateAssets="All" />
</ItemGroup>
</Project>
检查每个目标的 .cs 文件中的代码是否缺少引用,并在需要时更新 .csproj 文件中的引用。

不要在 NuGet 包中包含引用的包,也不会将其添加为包元数据中的依赖项。添加引用的包将导致无法在 Studio 中安装包。
步骤 2:构建解决方案
请务必在尝试构建项目之前测试项目是否存在错误。
从“生成”菜单中,选择“生成解决方案” 。系统会为每个目标框架构建 DLL 库,并将其保存在单独文件夹中的以下位置中: %UserProfile%\source\repos\MathSquareOfSum\MathSquareOfSum\bin\Debug
步骤 3:创建 NuGet 包
使用 NuGet 包资源管理器创建一个 NuGet 包,如使用代码(旧版)创建活动。
-
启动 NuGet 包资源管理器,然后单击“创建新包 (Ctrl + N)” 。系统将显示一个拆分窗口,其中显示“包元数据”和“包内容” 。我们需要在后一部分中添加所有依赖项。
-
在“包内容”部分中单击右键。系统将显示上下文菜单。
-
单击“添加库文件夹”。请注意,系统会在“包内容”部分创建新的“库”项目。
-
右键单击“库”两次,然后进行如下选择:
- 添加 .NET Framework 文件夹> v4.6.1
- 添加 .NET 文件夹> v6.0-windows
-
右键单击上一步中添加的每个文件夹,然后选择“添加现有文件”以加载每个所需的外部程序集 (
.dll) 文件。这些文件位于\bin\Debug文件夹中框架名称对应的子文件夹:- net461 - MathSquareOfSum.dll
- net6.0-windows - MathSquareOfSum.dll
-
将文件夹 net6.0-windows 重命名为
net6.0-windows7.0。 -
选中文件后,访问“编辑”菜单,然后选择“编辑元数据” 。左侧面板现在包含可编辑的元数据字段。
-
根据需要编辑元数据字段。
-
选择“编辑依赖项” ,然后添加以下目标框架: net461和net6.0-windows7.0 。

-
单击左上角的绿色复选标记按钮,以保存所有更改。
-
选择“文件” > “另存为” 以保存新文件。