This page offers an overview of how to migrate your custom .NET Framework activities to .NET 6 for use in projects with the Windows compatibility available starting with Studio 2021.10.6.
We will use the sample MathSquareOfSum .NET Framework activity documented on the Creating Activities With Code page as an example for a migration to .NET 6 that targets Windows while also maintaining compatibility with .NET Framework for Windows - Legacy projects.
A project that is using the .NET Framework project format must be migrated to the new SDK-style format. For more information, see the Microsoft documentation. Package references must be declared in the .csproj file as opposed to packages.config.
- In Solution Explorer, right click the project and select Unload Project.
- Copy references and clear everything from the
- Manually update the
.csprojfile to the new format.
- Add the target framework net6.0-windows.
- Mark the original references as net461 only by adding a condition.
- Add a new reference section with conditions for net6.0-windows. You must declare the following WWF dependencies for .NET: UiPath.Workflow.Runtime, UiPath.Workflow, System.Activities.Core.Presentation, System.Activities.Metadata.
Make sure all your dependencies support .NET. You might need to find newer package versions or replacement packages.
- In Solution Explorer, right click the project and select Reload Project.
The file should look as follows.
<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>
Check the code in the
.cs file for each target for missing references and update the references in the
.csproj file if needed.
Do not include the referenced packages in the NuGet package or add them as dependencies in the package metadata. Including the referenced packages results in a failure to install the package in Studio.
Make sure you test the project for errors before attempting to build it.
From the Build menu, select Build Solution. The DLL libraries are built and saved in the following location in separate folders for each target framework:
Create a NuGet package using NuGet Package Explorer, as described in Creating Activities With Code.
- Launch NuGet Package Explorer and click Create a new package (Ctrl + N). A split-window is displayed which shows Package metadata and Package contents. We need to add all dependencies in the latter section.
- Right-click inside the Package contents section. A context menu is displayed.
- Click Add lib folder. Notice a new lib item is created in the Package contents section.
- Right-click lib twice and select as follows:
- Add .NET Framework folder > v4.6.1
- Add .NET folder > v6.0-windows
- Right-click each of the folders added in the previous step and select Add Existing File to load the external assembly (
.dll) files required for each one. The files are located in a subfolder with the framework name located in the
- net461 - MathSquareOfSum.dll
- net6.0-windows - MathSquareOfSum.dll
- Rename the folder net6.0-windows to
- With the file selected, access the Edit menu and select Edit Metadata. The left panel is now fitted with editable metadata fields.
- Edit the metadata fields as needed.
- Select Edit dependencies, and then add the following target frameworks: net461 and net6.0-windows7.0.
- Click the green check mark button in the top-left corner save all changes.
- Select File > Save As to save the new file.
Updated 2 months ago